Programming frameworks are becoming more popular today as they allow developers to quickly build and deploy rather large-scale apps without having to do everything themselves. That said, they often have a rather steep learning curve, so running into errors is inevitable.
In this article, we’re looking at the Spring Boot Whitelabel error page, its causes and what you can do to fix the problem.
What is the Whitelabel error page?
The Whitelabel error page is a generic Spring Boot error page displayed when no custom error page is present. Why you might see an error page like this depends on the specific error in your app.
You can use this page to catch and display any errors in your app to the user as it provides a quick way of reporting client-end errors without having to write a custom page for each issue. However, you can replace it with a custom page that works within the same template but integrates better with your overall app’s design.
Also read: How to fix ‘Java: compilation failed: internal java compiler error’?
How to fix this?
The easiest way to fix this error is to disable the Whitelabel error page and providing a custom replacement instead.
Disabling the Whitelabel error page prevents it from being shown when your app runs into an error. You can do this in the application.properties file by changing the server.error.whitelabel.enabled flag to false.
server.error.whitelabel.enabled=false
Alternatively, you can disable the error page by excluding the ErrorMvcAutoConfiguration class.
@SpringBootApplication(exclude = {ErrorMvcAutoConfiguration.class}) public class Application { //code goes here }
Do keep in mind that if you disable the Whitelabel error page and no custom page is provided as a replacement, the web server’s default error page is shown.