mvn spring-boot:运行vs运行

jag*_*agr 5 spring intellij-idea maven livereload spring-boot

我正在使用intelliJ上的livereload测试spring-boot-devtools.我有简单的SpringBootApplication工作正常.

当我从maven命令"mvn spring-boot:run"启动应用程序时,一切正常,除了livereload服务器不启动.控制台上没有消息,Chrome扩展显示错误,无法连接到livereload服务器.

如果我启动应用程序(右摩丝按钮/运行Application.java),所有工作正常甚至livereload服务器.消息显示在控制台上,浏览器可以连接到livereload服务器.

从正确的慕斯按钮启动应用程序/运行Application.java

控制台消息

2016-07-13 16:39:47.947  INFO 10440 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-07-13 16:39:48.026  INFO 10440 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2016-07-13 16:39:48.077  INFO 10440 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-07-13 16:39:48.145  INFO 10440 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8090 (http)
Run Code Online (Sandbox Code Playgroud)

从mvn命令启动应用程序"mvn spring-boot:run"

Chorme扩展消息:

Could not connect to LiveReload server. Please make sure that a compatible LiveReload server is running. (We recommend guard-livereload, until LiveReload2 comes to your platform.)
Run Code Online (Sandbox Code Playgroud)

控制台消息.看到没有显示消息LiveReload服务器正在端口上运行....

2016-07-13 16:38:56.749  INFO 6924 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-07-13 16:38:56.852  INFO 6924 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-07-13 16:38:56.898  INFO 6924 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8090 (http)
Run Code Online (Sandbox Code Playgroud)

为什么maven命令不启动livereload服务器?

And*_*son 7

您需要告诉Maven分叉一个单独的JVM来运行您的应用程序,而不是它在与Maven相同的JVM中运行:

$ mvn spring-boot:run -Dfork=true
Run Code Online (Sandbox Code Playgroud)