Spring Boot Controller Not Mapping

Spring Boot Controller not mapping

I too had the similar issue and was able to finally resolve it by correcting the source package structure following this

Your Controller classes are not scanned by the Component scanning. Your Controller classes must be nested below in package hierarchy to the main SpringApplication class having the main() method, then only it will be scanned and you should also see the RequestMappings listed in the console output while Spring Boot is getting started.

Tested on Spring Boot 1.5.8.RELEASE

But in case you prefer to use your own packaging structure, you can always use the @ComponentScan annotation to define your basePackages to scan.

can't mapping the rest controller

Your packages have the wrong structure. You have to put them into your second demo, where your DemoApplicationis, not the first as you did. Then Spring will recognize them.

Here you can read about the package structuring in Spring Boot.



Related Topics



Leave a reply



Submit