Spring Boot项目在Mac下使用Maven启动时碰到的神奇问题:Unregistering JMX-exposed beans on shutdown
错误如下:
➜ springboottest1 mvn spring-boot:run [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building springboottest1 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> spring-boot-maven-plugin:1.4.7.RELEASE:run (default-cli) > test-compile @ springboottest1 >>> [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ springboottest1 --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/Jim/Desktop/springboottest1/src/main/resources [INFO] skip non existing resourceDirectory /Users/Jim/Desktop/springboottest1/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springboottest1 --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to /Users/Jim/Desktop/springboottest1/target/classes [WARNING] 读取/Users/Jim/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.15/tomcat-embed-core-8.5.15.jar时出错; invalid LOC header (bad signature) [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ springboottest1 --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/Jim/Desktop/springboottest1/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ springboottest1 --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to /Users/Jim/Desktop/springboottest1/target/test-classes [WARNING] 读取/Users/Jim/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.15/tomcat-embed-core-8.5.15.jar时出错; invalid LOC header (bad signature) [INFO] [INFO] <<< spring-boot-maven-plugin:1.4.7.RELEASE:run (default-cli) < test-compile @ springboottest1 <<< [INFO] [INFO] --- spring-boot-maven-plugin:1.4.7.RELEASE:run (default-cli) @ springboottest1 --- . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.4.7.RELEASE) 2017-08-17 15:50:23.713 INFO 2562 --- [ main] c.j.springboottest.springboottest1.App : Starting App on JimdeMacBook-Pro.local with PID 2562 (/Users/Jim/Desktop/springboottest1/target/classes started by Jim in /Users/Jim/Desktop/springboottest1) 2017-08-17 15:50:23.716 INFO 2562 --- [ main] c.j.springboottest.springboottest1.App : No active profile set, falling back to default profiles: default 2017-08-17 15:50:23.777 INFO 2562 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@220b740b: startup date [Thu Aug 17 15:50:23 CST 2017]; root of context hierarchy 2017-08-17 15:50:25.248 INFO 2562 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2017-08-17 15:50:25.267 INFO 2562 --- [ main] c.j.springboottest.springboottest1.App : Started App in 12.251 seconds (JVM running for 16.751) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.357 s [INFO] Finished at: 2017-08-17T15:50:25+08:00 [INFO] Final Memory: 30M/379M [INFO] ------------------------------------------------------------------------ 2017-08-17 15:50:25.494 INFO 2562 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@220b740b: startup date [Thu Aug 17 15:50:23 CST 2017]; root of context hierarchy 2017-08-17 15:50:25.496 INFO 2562 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
从上面的问题可以看出,是tomcat的Jar包读取失败,那么解决方法时进入到本地仓库把这个目录下的全部包删除,然后再重新构建即可解决。
总结:
一般使用Maven做依赖时,会碰到很多莫名其妙的问题,或许删除本地库的包再重新下载一次也是一种解决方法,尤其对于那种正确配置之后的项目不能运行的情况。