springboot中报Error starting ApplicationContext错误解决方法

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_39150374/article/details/98945718

前言

新手在使用springboot经常犯的错误,在引用其他项目中的类,经常会出现这样的错误。

错误再现

在这里插入图片描述

***************************
APPLICATION FAILED TO START
***************************

Description:

Field commonRepository in com.example.student.service.DocumentServiceImpl required a bean of type 'com.example.student.repository.CommonRepository' that could not be found.


Action:

Consider defining a bean of type 'com.example.student.repository.CommonRepository' in your configuration.


Process finished with exit code 1

造成这样的错误主要原因是启动类放置的问题引起的,比如本项目中启动类应该放在com.example下面而不是放在com.example.student下面

解决方法

1.将启动类放在com.example下面,具体做法:
先用鼠标选中要拆分的文件夹,右键选择ark Directory as,如图所示:
在这里插入图片描述
移出来之后再进行之前的操作,如图所示:
在这里插入图片描述
这样问题就解决了,再启动就不会出现问题了.
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_39150374/article/details/98945718