Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Write a Spring Boot Web Maven Archetype With Common Practices in Place

DZone's Guide to

How to Write a Spring Boot Web Maven Archetype With Common Practices in Place

This custom Spring Boot web Maven archetype can demonstrate common practices to help you bring these standards to your team or organization.

· Integration Zone ·
Free Resource

The new Gartner Critical Capabilities report explains how APIs and microservices enable digital leaders to deliver better B2B, open banking and mobile projects.

Here we are 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 can be imposed by your company or your team.

AppArchtype

The Maven archetype for the Spring Boot web application has all common standards in 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 the 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


A sample app generated from that archetype can be found on GitHub.

References:

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

The new Gartner Critical Capabilities for Full Lifecycle API Management report shows how CA Technologies helps digital leaders with their B2B, open banking, and mobile initiatives. Get your copy from CA Technologies.

Topics:
maven archetype ,jenkins pipeline ,lombok ,cucumber ,integration testing ,spring boot ,maven ,spring cloud ,integration

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}