Maven verify ClassNotFoundException for class of Spring Boot application

This problem can also manifest as a failure of integration test cases to find your application.properties resource.

This happens because of the interaction of the Spring Boot repackaging, done by the spring-boot-maven-plugin, and the logic that the maven-failsafe-plugin uses to set up the classpath for integration tests.

The Failsafe plugin puts the packaged JAR on the classpath, rather than the directory holding the unpacked classes and resources (as given by the project.build.outputDirectory property, which is usually ${basedir}/target/classes). However, the repackaging done by spring-boot-maven-plugin places the classes and resources of your application in an unusual location in the JAR, so although Failsafe examines the JAR, it does not find what it is looking for.

You can work around this problem by explicitly telling the Failsafe plugin to put the directory holding the unpacked classes and resources on using classpath, by using additionalClasspathElements in its configuration:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
            <additionalClasspathElements>
                <additionalClasspathElement>${basedir}/target/classes</additionalClasspathElement>
            </additionalClasspathElements>
            <includes>
                <include>**/*IT.java</include>
            </includes>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>integration-test</goal>
                    <goal>verify</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

OP problem solved by doing below,

This looks to be similar to what you are facing. Could you try with

<plugin>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-maven-plugin</artifactId>
   <configuration>
        <classifier>exec</classifier>
   </configuration>
 </plugin>

If you are not extending spring-boot-starter-parent, you have to add classesDirectory in your failsafe config (just as spring-boot-starter-parent pom does):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <!-- this one here! -->
        <classesDirectory>${project.build.outputDirectory}</classesDirectory>
    </configuration>
</plugin>

Found in a JIRA comment on a similar issue (failsafe 2.19+ not working with spring boot 1.4).