SoobinJung1013 / springboot-bestpractice

SpringBoot best practice architecture. Using Spring Security, Spring Data JPA.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SpringBoot best practice

springboot-bestpractice MIT License

About Spring Boot best practice architecture.

Environment variable

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

Spring Active Profiles (Local)

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

MySQL (5.5)

Sample query is sql/mysql_sample.sql file.

Sample Class

  • UserEntity.java
  • UserService.java
  • UserRepository.java
  • InfoEntity.java
  • InfoService.java
  • InfoRepository.java

Redis

Sample Class

  • UserService

Spring Active Profiles (Develop)

Develop development property file is application-dev.yml.

$ export SPRING_PROFILES_ACTIVE="dev"

Build

Git clone.

$ git clone https://github.com/tomoyane/springboot-bestpractice.git

Run test.

./gradlew test

Rub build.

./gradlew build 

Using docker container

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

Authentication and Authorization

Spring security.

JWT.

Architecture

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

License

MIT

About

SpringBoot best practice architecture. Using Spring Security, Spring Data JPA.

License:MIT License


Languages

Language:Java 98.6%Language:Shell 0.8%Language:Dockerfile 0.6%