spring-projects/spring-boot

Devtools Restarter is incompatible with Java 25 main method

Closed this issue · 2 comments

when you create a main method in the style of Java 25 like:

@SpringBootApplication
public class DemoApplication {

  void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
  }

}

and add devtools you get the following exception:

java.lang.IllegalStateException: Unable to find the main class to restart
	at org.springframework.util.Assert.state(Assert.java:79)
	at org.springframework.boot.devtools.restart.Restarter.doStart(Restarter.java:275)
	at org.springframework.boot.devtools.restart.Restarter.start(Restarter.java:263)
	at org.springframework.boot.devtools.restart.Restarter.lambda$immediateRestart$0(Restarter.java:171)
	at org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:612)
nosan commented

Duplicate of #35785

Thanks, @nosan.

@tompson it will work if you make the method static. However, looking at the code, I've just noticed that it won't work if the method's parameterless. I've opened #47986 for that.