Simple SpringBoot application using a database and provide a basic API.
- Java 11
- PostgreSQL database (H2 database for development profile)
One way to configure Spring applications is to use YAML configuration files.
Springboot, loads the application properties outside of your packaged jar from the application.yml
file.
Following is a simple YAML file that contains configuration for use PostgreSQL database datasource.
info:
app:
name: springusers
description: "springuser demo app"
version: 2.0.0
spring:
application:
name: springusers
datasource:
url: jdbc:postgresql://database:5432/sampledb
username: sampleuser
password: sampleuserpassword
platform: POSTGRESQL
jpa:
hibernate:
ddl-auto: create-drop
show-sql: true
server:
port: 8080
management:
endpoint:
health:
show-details: always
sensitive: false
endpoints:
web:
exposure:
include: prometheus, info, health, env
security:
enabled: false
metrics:
tags:
application: ${spring.application.name}
info:
env:
enabled: true
For the development mode the dev profile load the properties from src/main/resources/config/dev/application-dev.yml
.
To add a user make a POST like this example : http://localhost:8080/user/john.doe
To list all users : http://localhost:8080/user
Others useful endpoints:
/actuator/info
/actuator/health
/actuator/env
/actuator/prometheus
mvn -Dspring.profiles.active={dev-prod} spring-boot:run
mvn test
mvn package