springboot启动正常,访问restController报404


原因:spring boot只会扫描启动类当前包和以下的包 

比如以下:

主类:Application放在包com.springboot.main

controller类放在包com.springboot.controller

上面这处情况是找不到controller的

 

正确的做法是:

Application放在包com.springboot

controller类放在com.springboot.controller,这样相当于controller的在的包属于com.springboot底下。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM