The project is a Maven archetype for Spring SOAP/XML REST/JSON application.
It aims to serve to propose both an API based on REST/JSON and Web Services endpoints SOAP/XML
Web Services endpoints SOAP/XML are served by Apache CXF framework REST/JSON endpoints are served by Spring Framework MVC with Jackson JSON de/serialization
Notes: This archetype may not work with prior versions of Spring Framework 5.0.x, or 4.3.x, and Java < 1.8 It uses methods which are not reverse compatible.
When Spring Framework 5.2 will be released, this archetype must be upgraded accordingly.
PR contributions are welcome as long as there is no Spring Boot dependency included.
- Bill of Material
- Spring MVC web application, with Java config and no Spring Boot
- Apache CXF for the SOAP/XML web services endpoints
- Java Persistence (JPA) ** Spring Data JPA ** Hibernate ** HSQLDB ** H2 ** Postgresql
- Testing with JUnit/Mockito
- Docker containerization with Google Jib maven plugin
- Cache memory with Caffeine
- Jackson JSON/XML/CSV data-binding functionality
- Problem, implementation of the application/problem+json draft
- Lombok to reduce boilerplate code (cf readme of generated project)
- Unit tests with JUnit 5 Jupiter and Mockito
- JDK 8 (tested with Java 11)
- Apache Maven 3.6 (tested with 3.6.0)
- Not mandatory Docker
Beware: no pom.xml should be in directory where you run following command. For good measure create an empty directory.
Prerequisites: Java and Maven must be installed.
add to your ~/.m2/settings.xml a new repo in an activated profile
<repositories>
...
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
...
<repositories>
and run interactively in a directory without a pom.xml in it
mvn archetype:generate \
-DarchetypeGroupId=fr.ans \
-DarchetypeArtifactId=archetype-java \
-DarchetypeVersion=0.0.5
or with prior building of this archetype
mvn install
cd ..
mvn archetype:generate -DarchetypeCatalog=local
Indicate the properties of your generated project :
groupId: fr.ans
artifactId: archetype-java
version: 0.0.1-SNAPSHOT
package: fr.ans
parentArtifactId: bom-ms
parentGroupId: fr.gipcps.bom
parentVersion: 2.0.4
pipelineTemplate: AnsPipelineJdk8Mvn33
Y: :
Type "N" to enter your own values, and then type "Y" to confirm properties configuration.
Note : Concerning the property piplelineTemplate, only 2 values are allowed depending on your java version and maven version
For JDK 8 & Maven 3.3, Enter "AnsPipelineJdk8Mvn33"
For JDK 11 & Maven 3.6, Enter "AnsPipelineJdk11Mvn36"
- Create new project
File > New > Project
- Click Maven on the left hand side of the new project dialog
- Check
Create from archetype
- Click the
Add Archetype
button - Set
Group Id
tofr.ans
- Set
Artifact Id
toarchetype-java
- Set
Version
to0.0.5
- Click next and create the project
Note: If you would like to create a project using archetype published in your local repository, skip repository field and make sure it is installed locally (see below).
- Create new project
File > New > Maven Project
- Make sure
Create a simple project
option is not selected - Click
Next
to navigate toSelect an Archetype
screen - Make sure
Include snapshot archetypes
is selected - Click
Add Archetype
button - Set
Archetype Group Id
tofr.ans
- Set
Archetype Artifact Id
toarchetype-java
- Set
Archetype Version
to0.0.5
- Click
OK
so the Archetype is added to the list - Click
Next
and fill inGroup Id
,Artifact Id
andVersion
of your new project
Note: Remember to select Include snapshot archetypes
.
To install the archetype in your local repository execute the following commands:
git clone .../archetype-java
cd archetype-java
mvn clean install
Use a directory without a pom.xml in it and then run:
mvn archetype:generate \
-DarchetypeGroupId=fr.ans \
-DarchetypeArtifactId=archetype-java \
-DarchetypeVersion=0.0.5
Note: The above command will bootstrap a project using the archetype published in your local repository.
Docker must be installed
mvn compile jib:buildTar
docker load --input target/*.tar
docker run acme:0.0.5-dev
create a new server goto Preferences -> Server -> Runtime Environments
and add the project just created, publish, start the server
Navigate to newly created project directory (my-artifactId
) and then run:
mvn test tomcat7:run
Note: It is not recommended to run the artifact, Tomcat Maven Plugin Version 2.2 was released on 2013-11-11
Note: No additional services are required in order to start the application.
Prerequisites: PostgreSQL up and running, tablespace, and credentials valid
- Build and run with the correct profile:
mvn clean package -P-h2,dev,pgsql help:active-profiles
It is default DB activated, to change default reset to <activeByDefault>false</activeByDefault>
in POM
- Build and run with the correct profile:
mvn clean package -P dev,h2 help:active-profiles
- Build and run with the correct profile:
mvn clean package -P-h2,dev,hsql help:active-profiles
Prerequisites: MySQL up and running, tablespace, and credentials valid
- Build and run with the correct profile:
mvn clean package -P-h2,dev,mysql help:active-profiles