MongoDB vs. Redis comparison: Reference https://www.cnblogs.com/chinesern/p/5581422.html
1. Installing MongoDB Service
Reference: http://blog.csdn.net/IT_wanghe/article/details/53884229 not to do more instructions
Start command:e:/mongodb/bin>mongod--dbpath E:\mongodb\data\db Custom installation directory
2. Start MongoDB
3. Add Dependencies Daily
4. Adding an entity class @Id note It's important to add a metadata decoration @Id
to let spring know that this ID is the ID in the database
5. New interface todorepository inherit Mongorepository interface
Mongorepository: Similar to Hibernaterepository, through the inheritance of Mongorepository interface, we can easily implement the deletion of an object to change the search, to make
With the function of repository, inherit Mongorepository<t first,
Td> interface, where T is the bean class stored by the repository, and TD is the type of the bean's unique identity, typically objectid. This interface is then injected into the service to
Instead of implementing the inside method, spring is automatically generated according to the defined rules.
Reference: http://blog.csdn.net/codeiswhat/article/details/52129782
Package cn.cjq.bomb.util;
Import Cn.cjq.bomb.entity.Todo;
Import Org.springframework.data.mongodb.repository.MongoRepository;
Import Org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource (Collectionresourcerel = "Todo", Path = "Todo")
Public interface Todorepository extends Mongorepository<todo, string>{
}
6. The instance display did not pass the controller
Unknown principle, not to be continued ...
Springboot gradle Simple Integration MongoDB with notes