Spring Boot to exclude connecting to database during maven build

Include this in pom.xml to solve the problem.

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
    </plugin>

mvn clean install -DskipTests will work i think


Have similar issue, there is no need to disable all test with this plugin.

Just above main test class comment out or delete annotation:

//@SpringBootTest

Then when Maven build app, it will still run tests inside this class but will not run SpringBoot app, so will not test connection to DB and build will be successful.

Tags:

Spring Boot