Cloud Foundry(PCF)中的Spring Boot禁用Whitelabel错误页面

时间:2018-11-19 21:16:34

标签: spring spring-mvc spring-boot cloudfoundry pcf

相关问题: Spring Boot Remove Whitelabel Error Page

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

欢迎任何帮助和建议。

编辑: 我在Application上添加了exclude注释,然后在PCF上起作用。 以前我在application.yml中添加了排除配置,然后在PCF上不起作用

2 个答案:

答案 0 :(得分: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"
    }
}

答案 1 :(得分:0)

原来,断路器服务集排除属性比本地应用程序更有效。yml无效。如果我在回购中添加了排除属性,那么它将具有优先权。

我认为这是一种春季错误,因为排除是列表,所以它应该包括所有项目,而不是仅采用第一个配置。