- • Quickstart
- • Documentation
- • Documentation DevOps
- • Next Steps
- • Spring Data
- • Spring Data MongoDB
- • Spring REST
- • Frontend
- › Multi-Module
Last updated: 2022-08-23
Creating Test Jars in Maven for multi-module projects
Did you know that you can save days or weeks of development time when starting new Spring Boot apps? br With Bootify you have the right helper at your side - get a runnable prototype in minutes and focus on your business logic instead. Best practices included.
In multi-module projects, individual modules often contain classes or resources that should also be used in modules based on them - e.g. for initializing test users. In Maven, the
maven-jar-plugin can be used to create a referenceable test library for this purpose.
Suppose we have a simple Spring Boot application with two modules "base" and "web". An integration test in "web" now needs to access a method
initTestUsers, which is stored inside the "src/test/java" section in "base".
pom.xml of the module "base" must be extended to provide a jar of the test classes.
Adding maven-jar-plugin to the module providing the test data
Now the new library can be referenced from "web". The scope "test" makes it available for testing only, so it will not be included in the final "fat jar" of our Spring Boot executable.
Referencing the new test jar
Using Bootify, prototypes for Spring Boot applications can be created within minutes - develop a concept within the team first and then directly focus on the business logic. In the Professional Plan, the multi-module option is available, which automatically sets up the
maven-jar-plugin for Maven projects.