【问题标题】:Spring Boot in Cloud Foundry (PCF) disable Whitelabel Error PageCloud Foundry (PCF) 中的 Spring Boot 禁用 Whitelabel 错误页面
【发布时间】:2019-04-22 07:01:24
【问题描述】:

相关问题: Spring Boot Remove Whitelabel Error Page

就我而言, 我通过设置whitelabel.enabled = false 禁用了whitelabel,并且我还排除了ErrorMvcAutoConfiguration。它在常规的春季启动服务中工作。但是我在PCF cloud Foundry上部署了同样的服务,然后spring还是想把error重定向到/error页面。

欢迎任何帮助和建议。

编辑: 我在应用程序上添加了排除注释,然后它适用于 PCF。 之前我在 application.yml 中添加了排除配置,然后它在 PCF 上不起作用

【问题讨论】:

    标签: spring spring-mvc spring-boot cloud-foundry pcf


    【解决方案1】:

    您需要创建一个单独的端点/error,然后在方法中处理它。我建议您维护一个单独的controller 事实上。我的代码看起来像这样

    @RestController
    @RequestMapping(path = "/error")
    public class ErrorController {
    
        @ApiOperation(value = "Error Page", notes = "Error Page")
        @GetMapping
        public String error() {
            return "Some Error Occurred and I will Graciously show the Error"
        }
    }
    

    【讨论】:

    • 我不需要 /error 。我只想在发生错误时返回相应的http状态码。没有别的办法了吗?
    【解决方案2】:

    事实证明,断路器服务首先设置了排除属性,而不是本地 application.yml 没有生效。如果我在 repo 中添加排除属性,则优先考虑。

    我觉得这是一种spring bug,因为exclusion是list,所以应该包含所有item,而不是只取第一个配置。

    【讨论】:

      猜你喜欢
      • 2017-06-03
      • 1970-01-01
      • 1970-01-01
      • 2018-06-09
      • 1970-01-01
      • 1970-01-01
      • 2014-10-10
      • 2018-04-19
      • 2017-10-06
      相关资源
      最近更新 更多