Spring Boot Controller not mapping

前端 未结 9 1477
慢半拍i
慢半拍i 2021-02-05 02:55

I have used STS and now I am using IntelliJ Ultimate Edition but I am still getting the same output. My controller is not getting mapped thus showing 404 error. I am completely

9条回答
  •  失恋的感觉
    2021-02-05 03:05

    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.

提交回复
热议问题