How to write a spring boot web maven archetype with common practices in place

Here I am sharing a custom spring boot web maven archetype I have created to encapsulate all the common practices as an example how you can do the same in your team for common standards that could be imposed by your company or your team.

AppArchtype

the Maven archetype for Spring Boot web application which has all common standards on place ready for development

  • Java 1.8+
  • Maven 3.3+
  • Spring boot 1.5.6+
  • Lombok abstraction
  • JPA with H2 for explanation
  • Swagger 2 API documentation
  • Spring retry and circuit breaker for external service call
  • REST API model validation
  • Spring cloud config for external configuration on GIT repository
  • Cucumber and Spring Boot test for integration test
  • Jenkins Pipeline for multi branch project
  • continuous delivery and integration standards with Sonar check and release management
  • Support retry in sanity checks
  • Logback configuration

Installation

To install the archetype in your local repository execute following commands:

$ git clone https://github.com/Romeh/spring-boot-quickstart-archtype.git
$ cd spring-boot-quickstart-archtype
$ mvn clean install

Create a project

$ mvn archetype:generate \
     -DarchetypeGroupId=com.romeh.spring-boot-archetypes \
     -DarchetypeArtifactId=spring-boot-quickstart \
     -DarchetypeVersion=1.0.0 \
     -DgroupId=com.test \
     -DartifactId=sampleapp \
     -Dversion=1.0.0-SNAPSHOT \
     -DinteractiveMode=false

Test the generated app rest API via SWAGGER

http://localhost:8080/swagger-ui.html

Sample app generated from that archetype can be found here :

https://github.com/Romeh/spring-boot-sample-app

 

References :

  1. https://projects.spring.io/spring-boot/
  2. https://maven.apache.org/guides/introduction/introduction-to-archetypes.html
Advertisements

2 thoughts on “How to write a spring boot web maven archetype with common practices in place

  1. Learn Java April 19, 2018 / 5:26 pm

    Hi, Why I’m not able to change this groupid with some other custom name: DarchetypeGroupId=com.romeh.spring-boot-archetypes TO -DarchetypeGroupId=com.test.spring-boot-archetypes

    Like

    • mromeh April 20, 2018 / 9:38 am

      you need to change that in the arche type pom.xml first , as the archetype group id is defined there part of the maven archetype definition , then build install locally the new archetype so you can use it with ur archtype group name

      here the place :https://github.com/Romeh/spring-boot-quickstart-archtype/blob/master/pom.xml

      do the same locally when u clone the code in ur local workspace

      please let me know if u have any further questions or issues !

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s