问题
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