GithubHelp home page GithubHelp logo

rozuur / spring-boot-opinionated Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 68 KB

Opinionated setup of Spring Boot service

License: MIT License

Dockerfile 0.49% Java 91.13% Shell 8.37%
spring-boot static-analysis maven-plugins swagger-ui

spring-boot-opinionated's Introduction

spring-boot-opinionated

An opinionated setup of spring boot application

Java

Uses Java 11

Docker

Distroless is the base image.

As java is object-compatible, docker image is generated by copying the packaged jar. This is preferred over multi-stage docker, as multi-stage docker downloads internet

To build and run the application at port 8080 use docker run --rm -it -p8080:8080 $(docker build -q .)

Local Development

Start the application at port 8080 and debug port 5005 using mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

Code is auto formatted during compilation using formatter-maven-plugin and impsort-maven-plugin.

maven-enforcer-plugin is used to enforce java and mvn versions.

Database

Liquibase is used for database changes. SQL changes are present at src/main/resources/db/changelog

For testing, liquibase is disabled and h2 is used. Database entities are generated from classes instead of running changelog scripts.

Swagger

Swagger is exposed at /swagger-ui.html

REST API

APIs are exposed with a prefix, here it is /api/v1

APIs returns data transfer objects instead of entities, to reduce coupling of models to database schema.

POST APIs should return 201 Created with inserted resource PUT APIs should return updated resource

Actuator

actuator/health/readiness is health check endpoint for load balancer

actuator/health shows health stats

actuator/info API exposes git state through git-commit-id-plugin

actuator/prometheus API exposes metrics

actuator/loggers Used for changing log levels in runtime

Static Analysis

Following plugins are used for static analysis

  1. maven-pmd-plugin
  2. spotbugs-maven-plugin
  3. modernizer-maven-plugin

Testing

maven-surefire-plugin runs tests through maven.

jacoco-maven-plugin is used for code coverage

Release

mvn deploy fails if local modifications are present using maven-scm-plugin

maven-release-plugin is used in tools/jenkins_build.sh for release

maven-deploy-plugin is used for deploying to nexus repository if required

TODO

  1. Integrate Caching
  2. Integrate OAuth

spring-boot-opinionated's People

Contributors

rozuur avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.