OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.79k stars 6.57k forks source link

[BUG][JAVA] Multi-module spring-boot app gives errors about ApplicationContext and "multiple SLF4J bindings" warning #12375

Open LeonardGC opened 2 years ago

LeonardGC commented 2 years ago

Description:

TL;DR. I made a simple multi-module maven spring-boot app but building this fails with an error: Failed to load ApplicationContext caused by: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. ....

Details: I have made a spring boot app with 2 modules that build correclty. Adding the dependency of org.openapitools:openapi-generator:5.4.0 results in an error: Failed to load ApplicationContext (for the test unit) and was apparently caused by LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. ....

A few lines above this error I have this warning: SLF4J: Class path contains multiple SLF4J bindings.

Note that the addition of the dependency was enough for the exception to occur. No generation has been done!

I think the addition of this dependency should not result in an error in the app, especially because it seems related to the logging framework.

Facts

org.openapitools:openapi-generator:5.4.0 spring-boot application: 2.6.7 (from initializr converted to multi-module)

Code

5 Project files and a directory tree

Workaround I was able to workaround the issue by excluding the slf4j-simple artifact from the generator (see also commented code in OpenApi\pom.xml):

harel-biton commented 4 months ago

@wing328 I think this one can also be closed due to https://github.com/OpenAPITools/openapi-generator/pull/18881