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:

  1. Clone the https://github.com/johanhaleby/occurrent repository (git clone git@github.com:johanhaleby/occurrent.git)
  2. Switch branch to issue/spring-devtools
  3. Open the project in intellij or run mvn clean install -Dmaven.test.skip=true
  4. Open org.occurrent.example.domain.numberguessinggame.mongodb.spring.blocking.TestBootstrap class and run the main method (or step into example/domain/number-guessing-game/mongodb/spring/blocking and run mvn spring-boot:test-run)
  5. If you go to http://localhost:8080 you will see the application main page.
  6. Shut down the app and edit the example/domain/number-guessing-game/mongodb/spring/blocking/pom.xml file. Uncomment line 69-73 which adds the spring-boot-devtools dependency.
  7. Refresh the project in intellij and run the TestBoostrap class 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.