I have a very simple Java Springboot project connect to the database. Still, I want a mongoDB connection and I could use mongoDB as well.
I read lots of document and I can't make it work. And my commits code is:
https://github.com/GuoJing/spb/commit/20c04ce38d43bb0ba229d0d3577fdccbd571062e
If adding @AutoWired annotation, application will not start. I think this should be same as official document.
in src/main/java/controller/UserController.java
@Autowired
private UserPropsRepository userPropsRepository;
Here is my project, could anybody help me?
https://github.com/GuoJing/spb
My Exception is:
***************************
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.
Problem solved.
Related to this same problem and solution.
'Field required a bean of type that could not be found.' error spring restful API using mongodb
2.1.1.RELEASE
and the issue was solved..mvn
folder and rebuild my project and the issue was resolved.suppose you are missing @Repository annotation in the UserPropsRepository interface.
@repository("userPropsRepository")
public interface UserPropsRepository extends MongoRepository<UserProps, String> {
UserProps findOne(String id);
UserProps save(UserProps props);
UserProps update(UserProps props);
void delete(UserProps props);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.