Spring mvc mongodb crud users roles

Monday, June 12th, 2017 (0 Comment)

In this article, we will do simple project spring mvc mongodb. This simple project use spring-core library and mongodb database library. We should use spring-data-mongodb version 1.10.4.RELEASE and spring-core version 4.3.9.RELEASE, both of them is stable.

We need review Create maven project simple in Eclipse at section 1.

At first, we create structure of project as below:

spring mongodb

spring mongodb

1) Config libraries for spring mvc mongodb project

pom.xml to config maven

MongodbConfig.xml to config for mongo database

2) Define tables (mongo is Collections) in java spring mvc mongodb

Users.java

Roles.java

3) Test with many case spring mvc mongodb

3.1. Create 2 roles (admin, user) and 3 users (tommy1, tommy2, tommy3). Admin role have tommy1 and tommy2; User role have tommy1 and tommy2.

Output

Users collection

Roles collection

3.2. Update Roles

Output with Roles collection

3.3. Some way to query in spring mvc mongodb

Output

3.4. Remove admin role in tommy1 user and vice versa

Output

tommy1 user collection

admin role collection

 

Tags: , ,

Related Posts

spring
How to create quartz spring dynamic in database
spring
Java spring mvc tutorial on lvtutorial.com
spring
Angularjs spring mvc crud example
spring
How to upload sheet excel into database using Spring MVC

Related Posts

spring
How to create quartz spring dynamic in database
spring
Java spring mvc tutorial on lvtutorial.com
spring
Angularjs spring mvc crud example
spring
How to upload sheet excel into database using Spring MVC

Leave a Reply

Your email address will not be published. Required fields are marked *