How to build a Spring Boot jar without a database connection? This question would arise in conditions when you have no access to the database while building executable files such as jar for production.
For example, you are a freelance developer. Your client’s database servers won’t be exposed globally so you can’t build your project like your local development environment.
This is when you will have to tweak some configurations to make this possible.
To do this, I will share two options from which you can choose.
Tweaking pom.xml to skip database connections/tests
Add the following code in your file. It skips all the tests during the project build.
</plugin>Code language: HTML, XML (xml)
Tweaking build command to skip Tests
While building the project using maven tool, use the command given below.
mvn clean install -DskipTests
This command does the same function as tweaking the pom.xml file as shown above.
This command is the best way to build a Spring Boot jar without a database connection (to me, personally). I need not have to keep on changing my pom.xml file time and again.