Skip to content

Commit

Permalink
Spring Boot整合Mongo DB
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyouzhuguli committed Apr 4, 2019
1 parent 75b71a0 commit 951a3d2
Show file tree
Hide file tree
Showing 8 changed files with 632 additions and 0 deletions.
289 changes: 289 additions & 0 deletions 56.Spring-Boot-MongoDB-crud/Mongo DB crud.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
{
"info": {
"_postman_id": "8fa1e028-3088-4d19-bb08-4d41b3802487",
"name": "Mongo DB crud",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "createUser",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user?name=mike&description=python developer&age=21",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user"
],
"query": [
{
"key": "name",
"value": "mike"
},
{
"key": "description",
"value": "python developer"
},
{
"key": "age",
"value": "21"
}
]
}
},
"response": []
},
{
"name": "getUsers",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user"
]
}
},
"response": []
},
{
"name": "getUser",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user/5ca56280f08f0b6048fd470b",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user",
"5ca56280f08f0b6048fd470b"
]
}
},
"response": []
},
{
"name": "updateUser",
"request": {
"method": "PUT",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user/5ca40ee8f08f0b68cc06c001?id=5ca56280f08f0b6048fd470b&description=Java gosu&age=19",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user",
"5ca40ee8f08f0b68cc06c001"
],
"query": [
{
"key": "id",
"value": "5ca56280f08f0b6048fd470b"
},
{
"key": "description",
"value": "Java gosu"
},
{
"key": "age",
"value": "19"
}
]
}
},
"response": []
},
{
"name": "deleteUser",
"request": {
"method": "DELETE",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user/5ca56280f08f0b6048fd470b",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user",
"5ca56280f08f0b6048fd470b"
]
}
},
"response": []
},
{
"name": "getUsersStream",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user/stream",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user",
"stream"
]
}
},
"response": []
},
{
"name": "getUserByAge",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user/age/20/30",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user",
"age",
"20",
"30"
]
}
},
"response": []
},
{
"name": "getUserByName",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user/name/mrbird",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user",
"name",
"mrbird"
]
}
},
"response": []
},
{
"name": "getUserByDescription",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user/description/ui",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user",
"description",
"ui"
]
}
},
"response": []
},
{
"name": "getUserByCondition",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "localhost:8080/user/condition?size=2&page=0",
"host": [
"localhost"
],
"port": "8080",
"path": [
"user",
"condition"
],
"query": [
{
"key": "name",
"value": "mrbird",
"disabled": true
},
{
"key": "description",
"value": "r",
"disabled": true
},
{
"key": "size",
"value": "2"
},
{
"key": "page",
"value": "0"
}
]
}
},
"response": []
}
]
}
41 changes: 41 additions & 0 deletions 56.Spring-Boot-MongoDB-crud/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>mongodb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mongodb</name>
<description>Demo project for Spring Boot</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.mongodb;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MongodbApplication {

public static void main(String[] args) {
SpringApplication.run(MongodbApplication.class, args);
}

}
Loading

0 comments on commit 951a3d2

Please sign in to comment.