Springboot gradle Simple Integration MongoDB with notes

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.