前言
新手在使用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,如图所示:
移出来之后再进行之前的操作,如图所示:
这样问题就解决了,再启动就不会出现问题了.