Closed snicoll closed 8 years ago
bootRun
always forks so no downsides from a Gradle perspective.
An alternative could be to fork in Maven based on whether or not spring-boot-devtools
is on the classpath.
Actually, I much prefer that. We already fork based on the presence of an agent or jvmArguments so checking for devtools is just one more easy step to take.
@wilkinsona can we go as far as doing this in 1.4.1
?
I think so. The current behaviour isn't useful and it's inconsistent with how the Gradle plugin behaves.
Hi guys,
I have a Spring Boot 1.4.0 based project. I just noticed two things related to this issue after updating to version 1.4.1.
In IntelliJ Idea(Windows) I have set up a maven configuration "spring-boot:run -Dserver.port=8181" .
When executing the goal from the IDE
Setting
Please take a look at the plugin documentation.
In your case:
mvn spring-boot:run -DjvmArgs="server.port=8181"
Or
SERVER_PORT=8181 mvn spring-boot:run
Also: IntelliJ IDEA has native Spring Boot support, so there are easier ways to do this.
Thanks a lot for the link. It clears things up. I was able to pass the parameter with
mvn spring-boot:run -Drun.jvmArguments="-Dserver.port=8181"
I am using the community edition this is why I need plain maven.
Hello I use the maven build plugin from the commandline and cannot get devtools to work. Forking is enabled:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.0.RELEASE</version>
<configuration>
<fork>true</fork>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
devtools dependency is in dependencies section of pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
startup output:
2020-11-28 20:58:03.581 INFO 21988 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-11-28 20:58:03.581 INFO 21988 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
startup output with debugging on:
2020-11-28 21:15:10.995 DEBUG 22225 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Creating new Restarter for thread Thread[main,5,main]
2020-11-28 21:15:10.995 DEBUG 22225 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Immediately restarting application
2020-11-28 21:15:10.995 DEBUG 22225 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@7a8e95f4
2020-11-28 21:15:10.995 DEBUG 22225 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Starting application com.appengine.backend.Application with URLs [file:/Users/cubeo/ethicli/Website-and-Backend/target/classes/]
I'm at a loss for what the problem could be. I've tried everything I could think of.
SpringApplication.setRegisterShutdownHook(false)
in the codebaseI'm happy to provide any other info. In the meantime, I'll just keep restarting the dev server Thank you
@CubeOfCheese forking is enabled by default so you shouldn't have to do anything with recent Spring Boot versions. Perhaps you're missing the bits that the classpath has to be updated? Changing resources or code won't restart the server, you need to update the classpath as described in the documentation (see Triggering a restart). Arguably, this makes it harder to use it with only Maven, see #5136 for some more rationale.
Going forward, please do not comment on an issue to ask for support, especially on a closed one. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.
@snicoll Sorry about commenting for support. I'll use gitter in the future (just discovered it)
I realized that simply saving the file in a text editor wasn't sufficient and I instead needed to run mvn compile
I submitted a PR to update the docs to help make this more obvious to future users. https://github.com/spring-projects/spring-boot/pull/24271
It's a shame that the work necessary for #5136 was so substantial and out of scope. Thanks for your help
Devtools does not work if the app is started on the command line unless forking is enabled. Since we want a smooth experience of devtools, we should consider enabling forking in the parent so that it becomes the default.
Any downside to that approach?