An archetype which contains a sample Spring Boot REST API project
-
If the project
groupId
,artifactId
, andversion
is not specified the default valuescom.hackerrank.projects
,springboot-rest-api-sample
, and1.0.0-SNAPSHOT
respectively are used:mvn archetype:generate \ -DarchetypeGroupId=com.hackerrank.archetypes \ -DarchetypeArtifactId=springboot-rest-api \ -DarchetypeVersion=1.0.0
The generated project strucure is:
springboot-rest-api-sample ├── pom.xml └── src ├── main │ ├── java │ │ └── com │ │ └── hackerrank │ │ └── projects │ │ ├── Application.java │ │ └── controllers │ │ └── GreetingsController.java │ └── resources │ └── application.properties └── test └── java └── com └── hackerrank └── projects └── requests └── GreetingsControllerTest.java
The POM configuration is:
<groupId>com.hackerrank.projects</groupId> <artifactId>springboot-rest-api-sample</artifactId> <version>1.0</version> <packaging>jar</packaging>
-
The project
groupId
,artifactId
, andversion
could also be specified:mvn archetype:generate \ -DarchetypeGroupId=com.hackerrank.archetypes \ -DarchetypeArtifactId=springboot-rest-api \ -DarchetypeVersion=1.0.0 \ -DgroupId=my.group.id \ -DartifactId=my-artifact-id \ -Dversion=1.0
my-artifact-id ├── pom.xml └── src ├── main │ ├── java │ │ └── my │ │ └── group │ │ └── id │ │ ├── Application.java │ │ └── controllers │ │ └── GreetingsController.java │ └── resources │ └── application.properties └── test └── java └── my └── group └── id └── requests └── GreetingsControllerTest.java
The POM configuration is:
<groupId>my.group.id</groupId> <artifactId>my-artifact-id</artifactId> <version>1.0</version> <packaging>jar</packaging>
The archetype testing is done using the maven archetype plugin
. The tests are present in src/test/resources/projects
directory. The first test validates the project generation and runs code style checks and the second test validates build success by running tests on the generated project.
src/test/resources/projects
├── checkstyle
│ ├── archetype.properties
│ ├── goal.txt
│ └── verify.bsh
├── package
│ ├── archetype.properties
│ ├── goal.txt
│ └── verify.bsh
└── settings.xml