Does having spring-boot-actuator changes the context root of the spring application?

不打扰是莪最后的温柔 提交于 2019-12-12 04:44:00

问题


According to this post, by having the spring-boot-actuator dependency in pom.xml, I could benefits from the actuator endpoints. However, I observed it breaks my existing my spring application (It is not a spring-boot application).

I added the following to my dependency in pom.xml

      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
            <version>1.2.5.RELEASE</version>
       </dependency>

Thats it. I did not make any changes to application yet. I started the container using maven-t7-plugin. Now my application endpoint http://localhost:8010/mycontext/foo is returning 404. I commented out the above dependency in pom.xml. Now my application returns 200 OK for the above request.

Kindly help troubleshoot me as what is going wrong. I could not find any obvious reasons.

Thanks


回答1:


When I looked at the spring logs in console, I noticed the following: WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/mycontext/foo] in DispatcherServlet with name 'DispatcherServlet'.

Since I have configured DispatcherServlet in my Spring application, I cannot use auto-configure of spring-boot-actuator.

Once I excluded that dependency, my application works as expected.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-actuator</artifactId>
    <version>1.2.5.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId> 
            <artifactId>spring-boot-autoconfigure</artifactId>
        </exclusion>
    </exclusions>
</dependency>


来源:https://stackoverflow.com/questions/32383875/does-having-spring-boot-actuator-changes-the-context-root-of-the-spring-applicat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!