SpringBoot入门之访问Controller时的404

最近在研究springboot,发现启动时连controller都访问不了。我的springboot的启动类的配置如下:

controller层的配置如下:

 

服务启动以后我的访问路径为:localhost:8080/hello,可是页面一直报404,这是因为springboot服务启动后只会扫描启动类所在的包及以下的包。eg:启动类所在的包为com.spring.demo,那么其扫描的包为com.spring.demo.*

之后我将启动类改为:

问题解决! 

猜你喜欢

转载自blog.csdn.net/Hope_lee/article/details/86559568