Wednesday, August 23, 2017

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.BUILD-SNAPSHOT:start (pre-integration-test) on project start-stop-automatic-fork: Could not figure out if the application has started: Failed to connect to MBean server at port 50975: Spring application did not start before the configured timeout (30000ms -> [Help 1]

When building Spring Boot with "./mvnw clean install", you might encounter the following error:

[INFO] Exception in thread "main" java.lang.IllegalStateException: Shutdown should have been invoked by now
[INFO] at org.test.SampleApplication.main(SampleApplication.java:44)
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 34.455 s
[INFO] [INFO] Finished at: 2017-08-22T23:54:31+09:00
[INFO] [INFO] Final Memory: 23M/193M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.BUILD-SNAPSHOT:start (pre-integration-test) on project start-stop-automatic-fork: Could not figure out if the application has started: Failed to connect to MBean server at port 50975: Spring application did not start before the configured timeout (30000ms -> [Help 1]
[INFO] [ERROR]
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR]
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO]           start-stop-automatic-fork/pom.xml ................ FAILED (35.9 s)
[INFO]   The build exited with code 1. See /Users/izeye/IdeaProjects/spring-boot/spring-boot-tools/spring-boot-maven-plugin/target/it/start-stop-automatic-fork/build.log for details.

If you're using macOS Sierra (10.12.6), then try to modify "/etc/hosts" from:

127.0.0.1       localhost
::1             localhost

to:

127.0.0.1       localhost Johnnyui-MacBook-Pro.local
::1             localhost Johnnyui-MacBook-Pro.local

Reference:
https://thoeni.io/post/macos-sierra-java/