Spring Boot: Whitelabel Error Page solution

created at 11-10-2021 views: 22

This article is suitable for newbies who are new to me like me. If there is something wrong, please correct and criticize

I need to start building a new project due to my work. Spring boot is simple to build, especially suitable for people like me.

So I built and deployed the springboot project here, and deployed springboot according to the reference book

public class Platform1Application {

    public static void main(String[] args) {

        SpringApplication.run(Platform1Application.class, args);
    public String hello(){
        return "hello world";

Start the visit as follows

hello world

So I started to test the mysql database, and then I found that I couldn’t access it. The following figure shows the structure of my package.


package com.comservice.platform.controller;

import com.comservice.platform.javaBean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

 * @ClassName: com.comservice.platform.controller.UserController
 * @description: User control processing
 * @author: He bin
 * @create: 2021/11/3、9:33
 * @version: V1.0
public class UserController {
   JdbcTemplate jdbcTemplate;
    public List mySqlTest(){
       String sql="select * from user";
        List<User> users=jdbcTemplate.query(sql, new RowMapper<User>() {
            public User mapRow(ResultSet rs, int rowNum) throws SQLException {
                User user=new User();
               return  user;
        System.out.println("search successful"+users);
        return  users;


Then visit the page and find that it is Whitelabel Error Page

Whitelabel Error Page

After checking various information, I found that the controller package was not scanned, and it crashed.


Annotate the startup class

@ComponentScan(basePackages = {"com.comservice.platform.controller"})

As shown below

Annotate the startup class

created at:11-10-2021
edited at: 11-10-2021: