Skip to content

Commit 465c41e

Browse files
author
Gourav Rusiya
committed
2 parents efb5cca + 096e318 commit 465c41e

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,53 @@
1-
# SpringBootRestAPI
1+
# REST API: Java Spring Boot and MongoDB
2+
[![Travis Build Status](https://travis-ci.org/GouravRusiya30/SpringBootRestAPI.svg?branch=master)](https://travis-ci.org/GouravRusiya30/SpringBootRestAPI)
3+
4+
```Tech Stack Used in this project :```
5+
* Java
6+
* Spring Boot
7+
* Gradle
8+
* MongoDB
9+
* Postman
10+
11+
# Step 1: Creating a Database
12+
Get a running instance of MongoDB that you can connect to.
13+
For more information on getting started with MongoDB, visit their [online tutorial](https://docs.mongodb.com/manual/).
14+
15+
Start by creating a test database. I will call mine "rest_tutorial" using the following command in the MongoDB shell, or through a database manager like MongoDB Compass:
16+
```use rest_tutorial;```
17+
This will create a new database in MongoDB that we can use for our tutorial.
18+
19+
# Step 2: Adding a MongoDB Collection and Data
20+
Create a sample collection that will hold data about different types of pets. Let's create the collection with the following command:
21+
22+
```db.createCollection("pets");```
23+
Once the collection is created, we need to add some data!
24+
We can add data to the collection with the following command:
25+
26+
```db.pets.insertMany([```
27+
```{```
28+
```"name" : "Spot",```
29+
```"species" : "dog",```
30+
```"breed" : "pitbull"```
31+
``` },```
32+
```{```
33+
```"name" : "Daisy",```
34+
```"species" : "cat",```
35+
```"breed" : "calico"```
36+
```},```
37+
```{```
38+
```"name" : "Bella",```
39+
```"species" : "dog",```
40+
```"breed" : "australian shepard"```
41+
```}```
42+
```]);```
43+
44+
# Step 3: Adding mongodb credentials
45+
Add the mongodb authentication-database, username & password in [application.properties](https://github.com/GouravRusiya30/SpringBootRestAPI/blob/master/src/main/resources/application.properties)
46+
If there is no authrntication when you are running locally then you can also remove these properties from this file.
47+
48+
# Step 4: Testing Your API
49+
Once the server starts, you are free to test your API however you choose.
50+
For example :
51+
* POST 'http://localhost:8080/pets'
52+
With body : ```{"name" : "Liam", "species" : "cat", "breed" : "tabby"}```
53+
and header : ```'Content-Type: application/json'```

0 commit comments

Comments
 (0)