Starter application for REST API with spring framework and mongodb. This project is based on the https://github.com/kennycyb/spring-rest-api-starter, with added connectivity to MongoDB.
Refer to https://docs.spring.io/spring-boot/docs/current/reference/html/ for more information.
Use WAR packaging:
<packaging>war</packaging>
Use Spring Framwork
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
</parent>
Dependencies
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
spring:
data:
mongodb:
host: localhost
port: 27017
database: spring-rest-api
spring:
data:
mongodb:
host: ${SPRING_MONGO_HOST}
port: ${SPRING_MONGO_PORT}
database: spring-rest-api
Edit /usr/share/tomcat8/bin/setenv.sh, add "SPRING_MONGO_HOST" and "SPRING_MONGO_PORT", example:
export CATALINA_OPTS=" \
...
...
-DSPRING_MONGO_HOST=localhost \
-DSPRING_MONGO_PORT=27017
"
Key | Value | Description |
---|---|---|
SPRING_PROFILES | openshift | Load the application-openshift.yml |
SPRING_MONGO_HOST | hostname | |
SPRING_MONGO_PORT | port | |
SPRING_MONGO_USER | user | |
SPRING_MONGO_PASSWORD | password | |
SPRING_MONGO_DATABASE | database |