Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/CleverCloud/springboot-mongo-example
Run Spring Boot with MongoDB on Clever Cloud
https://github.com/CleverCloud/springboot-mongo-example
clevercloud-example mongodb spring-boot
Last synced: 2 months ago
JSON representation
Run Spring Boot with MongoDB on Clever Cloud
- Host: GitHub
- URL: https://github.com/CleverCloud/springboot-mongo-example
- Owner: CleverCloud
- Created: 2017-07-06T09:28:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-15T08:53:09.000Z (almost 3 years ago)
- Last Synced: 2024-08-25T12:01:13.563Z (5 months ago)
- Topics: clevercloud-example, mongodb, spring-boot
- Language: Java
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 16
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-clever-cloud - demo-springboot-mongo-rest
README
# Spring Boot as RESTful Demo for Clever-Cloud
## Description
This is a small Spring Boot app that uses java + maven Clever Cloud application type.
This is a RESTful app which is using the MongoDB addon.
## Features
As a RESTful you can use HTTP requests like:
- `GET /users`
- `GET /users/{userId}`
- `POST /users "body": {"firstName":"Robert", "lastName":"Cloud"}`
- `DELETE /users/{userId}`## Model
```json
"users":[
{
"id" : "...",
"firstName" : "...",
"lastName" : "..."
}
]
```## Configuration
### MongoDB
MongoDB URI is set in `src/main/resources/application.properties` and looks like:
```java
spring.data.mongodb.uri=${MONGODB_ADDON_URI}
```Where `MONGODB_ADDON_URI` is an environment variable which is specified by MongoDB addon link.
## Install and run locally
- install dependencies: `mvn install`
- tests: `mvn test`
- run: `mvn spring-boot:run`## Deploy on the Clever Cloud console
Create a mongodb add-on and link it to your app.
### Set the goal in the environment
In the environment variables, create `MAVEN_DEPLOY_GOAL` and set it to `spring-boot:run`
## Example
Create new user
```bash
curl -d '{"firstName":"Robert", "lastName":"Cloud"}' -H "Content-Type: application/json" -X POST https://.cleverapps.io/users
```Get users list
```bash
curl -X GET https://.cleverapps.io/users
```Find user by id
```bash
curl -X GET https://.cleverapps.io/users/
```Remove user by id
```bash
curl -X DELETE https://.cleverapps.io/users/
```## Test
I wrote an example of test in `src/test/java/com/cc/demo/test/UserMongoRepositoryTest.java` which is called during `mvn test`.