今晚初识SpringBoot,按照官网引导创建了SpringBoot的HelloWorld。在启动时报Unregistering JMX-exposed beans on shutdown的错误。日志如下:
run main class:SpringbootJdbcApplication Application
2018-02-05 10:25:19.795 INFO 93703 --- [main] o.s.j.e.a.AnnotationMBeanExporter: Registering beans for JMX exposure on startup
2018-02-05 10:25:19.814 INFO 93703 --- [main] c.e.s.SpringbootJdbcApplication: Started SpringbootJdbcApplication in 2.272 seconds (JVM running for 3.018)
2018-02-05 10:25:19.815 INFO 93703 --- [Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@3bd94634: startup date [Mon Feb 05 10:25:18 CST 2018]; root of context hierarchy
2018-02-05 10:25:19.817 INFO 93703 --- [Thread-2] o.s.j.e.a.AnnotationMBeanExporter: Unregistering JMX-exposed beans on shutdown
经过度娘搜索,添加了SpringBoot对tomcat的maven依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
结果还是不尽人意...
再经度娘谷哥数次,试验多次后发现maven下载的tomcat系列jar包有损坏的情况?。(可能是下载时网络或其他原因导致)
然后找到repository/org/apache/tomcat 将其干掉。然后重新执行
Maven Update Project ..
Maven Clear
Maven Install
Run As Spring Boot App 或 mvn package && java -jar target/gs-spring-boot-0.1.0.jar 启动工程
日志如下:
spring.http.encoding-org.springframework.boot.autoconfigure.http.HttpEncodingProperties
spring.info-org.springframework.boot.autoconfigure.info.ProjectInfoProperties
spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties
spring.mvc-org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties
spring.resources-org.springframework.boot.autoconfigure.web.ResourceProperties
spring.servlet.multipart-org.springframework.boot.autoconfigure.web.servlet.MultipartProperties
springApplicationAdminRegistrar
springBootHelloController
standardJacksonObjectMapperBuilderCustomizer
stringHttpMessageConverter
tomcatServletWebServerFactory
tomcatServletWebServerFactoryCustomizer
tomcatWebServerFactoryCustomizer
viewControllerHandlerMapping
viewResolver
webServerFactoryCustomizerBeanPostProcessor
websocketContainerCustomizer
welcomePageHandlerMapping
2018-11-07 03:06:24.684 INFO 5194 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-11-07 03:06:24.684 INFO 5194 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-11-07 03:06:24.696 INFO 5194 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 12 ms
浏览器访问 http://localhost:8080 或 curl localhost:8080
显示结果:
搞定