【问题标题】:Does having spring-boot-actuator changes the context root of the spring application?是否拥有 spring-boot-actuator 会改变 spring 应用程序的上下文根?
【发布时间】:2015-09-03 19:23:51
【问题描述】:

根据this post,通过在pom.xml 中拥有spring-boot-actuator 依赖项,我可以从actuator 端点中受益。但是,我观察到它破坏了我现有的 spring 应用程序(它不是 spring-boot 应用程序)。

我在 pom.xml 中的依赖项中添加了以下内容

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

就是这样。我还没有对应用程序进行任何更改。 我使用maven-t7-plugin 启动了容器。 现在我的应用程序端点http://localhost:8010/mycontext/foo 返回404。我在pom.xml 中注释掉了上面的dependency。 现在我的应用程序为上述请求返回200 OK

请帮助我解决问题所在。我找不到任何明显的原因。

谢谢

【问题讨论】:

  • 它不应该改变上下文,而是它可能以某种方式期望您的页面位于其他位置?也许它启用了spring boot web。给我们看一些代码。
  • 我怀疑执行器不能很好地运行,因为它不是弹簧启动应用程序。
  • @ACV。我尝试了我们的生产代码。我不能在这里分享。但测试它很简单。同时我会在这里放一些简单的代码
  • @spencergibb: 是否有可能仅仅通过依赖就破坏现有的应用程序?
  • @brainstorm,foo 的实际值是多少?

标签: spring-boot spring-boot-actuator


【解决方案1】:

当我查看控制台中的 spring 日志时,我注意到以下内容: WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/mycontext/foo] in DispatcherServlet with name 'DispatcherServlet'.

由于我在我的 Spring 应用程序中配置了DispatcherServlet,我不能使用auto-configurespring-boot-actuator

一旦我排除了dependency,我的应用程序就会按预期工作。

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

【讨论】:

    猜你喜欢
    • 2018-03-08
    • 1970-01-01
    • 1970-01-01
    • 2019-08-13
    • 2014-10-28
    • 1970-01-01
    • 2020-05-16
    • 2019-03-31
    相关资源
    最近更新 更多