Search code examples
spring-bootdockermavenbuildpack

Why does "spring-boot:build-image" run the Spring Boot application?


Two simple questions:

  1. Why is a Spring Boot application executed while creating a Docker image with the mvnw spring-boot:build-image command?
  2. Is there a command line option to prevent this from happening?

I am building a Docker image for a Spring Boot application. The application depends on other, third party services which are not necessarily (and also shouldn't be) available during the image build process. Hence, the image build fails, since the Spring Boot application checks those third party dependencies on start-up and tries to reconnect until they become available. Side remark: the latter cannot be changed since this is built-in in the framework for the third party service being used.

I also don't understand why the application should actually be started to build a Docker image.

Thank you for responding and possibly the additional background information.


Solution

  • I found out an alternative approach might be to add an application.properties file in the src/test/resources folder in which you add axon.axonserver.enabled=false

    Doing so allows you to run tests without having a running Axon Server instance available.

    This is probably not the best possible solution, but for now, it does the trick ;-)