Skip to content
Advertisement

whitelabel error page 404 spring boot microservices Rest Controller

I am new to Spring Boot and Microservices. I have created RestController and tried to check using RequestMapping test but it give us error as 404, whitelabel error page.

Below is pom.xml :

JavaScript

Below is the code for the controller

JavaScript

Below is Spring boot main class

JavaScript

Server Start up logs are mentioned below :

JavaScript

Any help will be appreciated. Thanx in advance

Advertisement

Answer

The issue is that your Controller is not being scanned and thus no Spring-managed Bean is created. Move your main CitizenDetailServiceApplication class to the package com.example.microservices, which should be your parent package for any other sub-packages you create.

JavaScript

@SpringBootApplication encapsulates @Configuration, @EnableAutoConfiguration, and @ComponentScan annotations with their default attributes. The default value for @ComponentScan means that all the sub-packages on the package the @ComponentScan is used are scanned. That is why it is usually a good practice to include the main class in the base package of the project.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement