想根据spring boot官网的demo写一个webservice的程序,但是一直报错:Unregistering JMX-exposed beans on shutdown
控制台输出如下:
2018-01-05 16:27:17.681 INFO 6616 --- [ main] hello.Application : Starting Application on NH7A716BY4S5KHD with PID 6616 (E:\Dev\workspace-eclipse\testlog\target\classes started by Administrator in E:\Dev\workspace-eclipse\testlog)
2018-01-05 16:27:17.684 INFO 6616 --- [ main] hello.Application : No active profile set, falling back to default profiles: default
2018-01-05 16:27:17.742 INFO 6616 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2698dc7: startup date [Fri Jan 05 16:27:17 CST 2018]; root of context hierarchy
2018-01-05 16:27:18.808 INFO 6616 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-01-05 16:27:18.823 INFO 6616 --- [ main] hello.Application : Started Application in 1.438 seconds (JVM running for 1.79)
2018-01-05 16:27:18.824 INFO 6616 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@2698dc7: startup date [Fri Jan 05 16:27:17 CST 2018]; root of context hierarchy
2018-01-05 16:27:18.825 INFO 6616 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
网上普遍的解决方案是在pom.xml文件添加以下依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
但是官方文档中有明确说明spring-boot-starter-web默认用的就是tomcat内嵌容器,所以我认为这不是导致问题的原因,不过我还是以试一试的态度加了该依赖,果然没有作用。网上解决方案找了半天,还是没能解决问题。所以我感觉这可能是spring boot的一个bug,于是我以试一试的心态将以下依赖版本,由目前最高版本降到了低一版本,再运行程序,OK
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.7.RELEASE</version>
<!-- <version>1.5.9.RELEASE</version> -->
</parent>
也就是说1.5.9版本的spring boot可能存在导致该异常的bug,至于到底是不是个bug以及具体导致bug的原因,需要查看源码或者去官方论坛进一步探究
未完待续
//TODO 找到报错的具体原因