Search code examples
javaspring-bootmaven

Spring boot maven package


I am running a mvn package for my Spring Boot app but it automatically starts the app too and try to connect to the datasource I set up. Is there a way to disable thisI I just want my jar when I package. Is it maybe the spring boot maven plugin doing this?

    <build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

   

Solution

  • If you run mvn clean package command then Maven will

    1. delete target directory
    2. compile all classes
    3. run all tests
    4. build the executable JAR

    The tests can connect to the database and this is probably what you observe. To skip the tests you should call:

    mvn clean package -DskipTests