1

相关问题: Spring Boot Remove Whitelabel Error Page

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

欢迎任何帮助和建议。

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

4

2 回答 2

0

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

我觉得这是一种spring bug,因为排除是列表,它应该包括所有项目,而不是只取第一个配置。

于 2018-11-20T15:08:39.947 回答
0

您需要创建一个单独的端点/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"
    }
}
于 2018-11-20T06:23:43.447 回答