简体   繁体   中英

Spring Boot in Cloud Foundry (PCF) disable Whitelabel Error Page

Related question: Spring Boot Remove Whitelabel Error Page

For my case, I disabled whitelabel by setting whitelabel.enabled = false , and I also exclude ErrorMvcAutoConfiguration. It worked in regular spring boot service. But I deployed the same service on PCF cloud foundry, then spring still want to redirect error to /error page.

Any help and suggestion is welcome.

Edit: I added exclude annotation on Application, then it works on PCF. Previously I added exclude configuration in application.yml, then it didn't work on PCF

You need to create a separate endpoint /error and then handle it in the method. I would suggest you to maintain a separate controller infact. My code would look something like this

@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"
    }
}

It turns out circuit breaker service set exclusion property first, than local application.yml didn't take effect. If I add exclusion property in repo, then it take preference.

I feel this is kind of spring bug, since exclusion is list, it should include all items, instead of taking the first configuration only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM