spring boot starter工程启动就关闭的问题

配置了maven中的mirror后,maven用起来就像是飞一般的感觉。

<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

近期在入手Spring框架,经过十几年沉淀的东西,确实博大精深。

作为Starter(老菜鸟)翻了几本过时的pdf后,终于痛下决心从http://spring.io/guides开始一点一点的啃。

第一个hello world webserivce工程,就遇到了一个神奇的问题

Spring shutdown on start up!!!具体的错误,居然不是用ERROR标识,而是用info

INFO 4068 --- [lication Thread] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext

INFO 4068 --- [lication Thread] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown

这坑爹的货。但是按着教程操作的东西都会出错。。W.H.Y?

原来使用Spring Tool Suite(STS)向导(Import Spring Getting Started Content)新建的Rest 工程中自带的pom.xml文件内容与http://spring.io/guides中的内容不符。

重点是少了如下依赖:

<dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-test</artifactId>

            <scope>test</scope>

        </dependency>

        <dependency>

            <groupId>com.jayway.jsonpath</groupId>

            <artifactId>json-path</artifactId>

            <scope>test</scope>

        </dependency>

补上,就不会一启动就自动关闭Spring了。

-----------------------------------------------------------------------------------

就跟小时候做语文课后习题一样——答案就在文章中。

BTW,今天看的是

Building a RESTful Web Service

holy血,一把年纪了还在hello world,8特,I DO LIKE IT.

Spring shutdown on start up

原文地址:https://www.cnblogs.com/rain64531264/p/8120602.html