Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn spring-boot:run vs Run

I'm testing spring-boot-devtools with livereload on intelliJ. I have simple SpringBootApplication that works fine.

When I start the app from maven command "mvn spring-boot:run" all works fine excepting that livereload server dont' start. No message on console appears and the chrome extensions show error that It's not possible to connect to livereload server.

If I start app with (right mousse button/Run Application.java), all works fine even livereload server. Message appears on console and browser is able to connect to livereload server.

Starting app from right mousse button/Run Application.java

Console message

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)

Starting app from mvn command "mvn spring-boot:run"

Chorme extension message:

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.)

Console message. See that not show message LiveReload server is running on port....

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)

Why maven command don't start livereload server?

like image 573
jagr Avatar asked Jul 13 '16 14:07

jagr


People also ask

What does mvn Spring Boot run?

Introduction. The Spring Boot Maven Plugin provides Spring Boot support in Apache Maven. It allows you to package executable jar or war archives, run Spring Boot applications, generate build information and start your Spring Boot application prior to running integration tests.

What is run () in Spring Boot?

boot. In startup process after the context is initialized, spring boot calls its run() method with command-line arguments provided to the application. To inform spring boot about our commandlineRunner interface, we can either implement it and add @Component annotation above the class or create its bean using @bean.

What is a purpose of SpringApplication run?

Spring Boot SpringApplication class is used to bootstrap and launch a Spring application from a Java main method. This class automatically creates the ApplicationContext from the classpath, scan the configuration classes and launch the application.


1 Answers

You need to tell Maven to fork a separate JVM to run your application, rather than it running in the same JVM as Maven:

$ mvn spring-boot:run -Dfork=true
like image 185
Andy Wilkinson Avatar answered Oct 13 '22 01:10

Andy Wilkinson