Without spring-boot-devtools I can start my application just fine, but when I add:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>optional</scope>
</dependency>
then my application won't start because it complains about a missing bean.
To reproduce do this:
- Clone the https://github.com/johanhaleby/occurrent repository (
git clone git@github.com:johanhaleby/occurrent.git) - Switch branch to
issue/spring-devtools - Open the project in intellij or run
mvn clean install -Dmaven.test.skip=true - Open
org.occurrent.example.domain.numberguessinggame.mongodb.spring.blocking.TestBootstrapclass and run the main method (or step intoexample/domain/number-guessing-game/mongodb/spring/blockingand runmvn spring-boot:test-run) - If you go to http://localhost:8080 you will see the application main page.
- Shut down the app and edit the
example/domain/number-guessing-game/mongodb/spring/blocking/pom.xmlfile. Uncomment line 69-73 which adds thespring-boot-devtoolsdependency. - Refresh the project in intellij and run the
TestBoostrapclass again.
Expected: The application should start Actual:
2024-06-07T15:59:00.343+02:00 INFO 36216 --- [number-guessing-game] [ restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-06-07T15:59:00.363+02:00 ERROR 36216 --- [number-guessing-game] [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in org.occurrent.example.domain.numberguessinggame.mongodb.spring.blocking.view.gamestatus.impl.SpringGameStatusFinder required a bean of type 'org.occurrent.dsl.query.blocking.DomainEventQueries' that could not be found.
Action:
Consider defining a bean of type 'org.occurrent.dsl.query.blocking.DomainEventQueries' in your configuration.
Process finished with exit code 0
I guess that this can't be intentional?
Comment From: wilkinsona
The problem's occurring due to Devtools split class loader with DomainEventQueries being loaded by both the app class loader and the Devtools restart class loader. Unfortunately, there's far too much to the supplied application for me to figure out why that's the case. It may be a bug in the application if it's doing any custom class loading or proxying, or it may just be that you need to customize the restart class loader.
If that doesn't help and you'd like us to investigate further, please create a minimal sample that reproduces the problem and we can re-open the issue and take another look.