OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] Multi-module spring-boot app gives errors about ApplicationContext and "multiple SLF4J bindings" warning
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
- Tree.txt: shows the directory structure
- \pom.xml
- \OpenApi\pom.xml
- \server\pom.xml
- \server\src\main\java\com\example\demo\DemoApplication.java
- \server\src\test\java\com\example\demo\DemoApplicationTests.java
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):
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked root, OpenApi, and server pom.xml files, then inspect server/src/test/java/com/example/demo/DemoApplicationTests.java. Run the test with org.openapitools:openapi-generator:5.4.0 present and compare it with the slf4j-simple exclusion workaround. Done means the multi-module Spring Boot test runs without the ApplicationContext failure or multiple-binding warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend, build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100