About Spring Boot best practice architecture.
Name | Description |
---|---|
SPRING_PROFILES_ACTIVE | Spring runtime environment |
MYSQL_DB_HOST | Database host |
MYSQL_DB_NAME | Database name |
MYSQL_DB_USER | Database username |
MYSQL_DB_PASS | Database password |
REDIS_DB_HOST | Redis host |
REDIS_DB_PORT | Redis port |
REDIS_DB_PASS | Redis password |
Local development property file is application-local.yml.
$ export SPRING_PROFILES_ACTIVE="local"
Working on docker container.
- Docker Image
- MySQL
- Redis
- OpenJDK
Cassandra cluster.
- CentOS7 virtual machine
- 3 nodes
Sample query is sql/mysql_sample.sql file.
Sample Class
- UserEntity.java
- UserService.java
- UserRepository.java
- InfoEntity.java
- InfoService.java
- InfoRepository.java
Sample Class
- UserService
Develop development property file is application-dev.yml.
$ export SPRING_PROFILES_ACTIVE="dev"
Git clone.
$ git clone https://github.com/tomoyane/springboot-bestpractice.git
Run test.
./gradlew test
Rub build.
./gradlew build
Docker image build
- Build SpringBoot best practice application.
- Use docker for local development.
- MySQL
- Redis
- OpenJDK
$ docker-compose build
Run container
$ docker-compose up -d
Spring security.
JWT.
spring-boot-bestpracite
├── main
│ ├── java
│ │ └── com
│ │ └── bestpractice
│ │ └── api
│ │ ├── App.java
│ │ ├── common
│ │ │ ├── config
│ │ │ ├── property
│ │ │ └── util
│ │ │
│ │ ├── controller
│ │ │ ├── Advice.java
│ │ │ ├── v1
│ │ │ └── v2
│ │ │
│ │ ├── domain
│ │ │ ├── entity
│ │ │ ├── model
│ │ │ ├── repository
│ │ │ └── service
│ │ │
│ │ ├── exception
│ │ │
│ │ └── security
│ │ ├── filter
│ │ └── role
│ │
│ └── resources
│ ├── application-dev.yml
│ └── application-local.yml
└── test
├── java
│ └── com
│ └── bestpractice
│ └── api
│ ├── AppTests.java
│ │
│ ├── common
│ │
│ ├── controller
│ │
│ ├── repository
│ │
│ └── service
│
└── resources
└── application-test.yml