我有一个非常简单的Java SpringBoot项目连接到数据库。不过,我想要一个MongoDB连接,我也可以使用MongoDB。
我读了很多文件,但我不能让它发挥作用。我的提交代码是:
https://github.com/GuoJing/spb/commit/20c04ce38d43bb0ba229d0d3577fdccbd571062e
如果添加@AutoWire注解,应用程序将不会启动。我认为这应该和官方文件一样。
在src/main/Java/control/UserController.java中
@Autowired
private UserPropsRepository userPropsRepository;
这是我的项目,有人能帮我吗?
https://github.com/GuoJing/spb
我的例外是:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userPropsRepository in controller.UserController required a bean of type 'repository.UserPropsRepository' that could not be found.
Action:
Consider defining a bean of type 'repository.UserPropsRepository' in your configuration.
3条答案
按热度按时间pcrecxhr1#
问题解决了。
1.更改我的项目结构,移动根包、模型和DAO...要来.例如.
1.将Application.java移动到根目录,以便它将自动扫描组件
与此相关的问题和解决方案。
'Field required a bean of type that could not be found.' error spring restful API using mongodb
bqjvbblv2#
2.1.1.RELEASE
,问题得到解决。.mvn
文件夹并重建我的项目,问题已解决。ijxebb2r3#
假设您在UserPropsRepository接口中缺少@Repository注解。