maven-compiler-plugin could not found class in spring boot application

134 Views Asked by At

i had a strange issue in my spring boot application. Pls help me to found out the cause, thanks in advance!

Description I had module A and module B in my application, module B is a set of functional tests for module A, B have dependencies in module A so i add A as a dependency of B. When i want to do functional tests, i ran application A and then run functional tests in module B, it works well. But when i do mvn clean install, module B will raise exception in maven-compiler plugin, which says it could not found classes referenced from module A, while in my IDE and during runtime, it works fine.

Could anyone help me to figure out this question? thanks

i tried to change pom.xml configuration, and change scope of module A dependency, both did not work

1

There are 1 best solutions below

0
maihexi On

problem solved, this class not found is due to spring-boot-maven-plugin repackage, this plugin repackage maven build jar to a jar which can be deployed as web service, but this jar could not be imported or use as dependency, so we should change the spring-boot-maven-plugin configuration, and generate two jar, one is used as dependency and the other is used to deploy.

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <classifier>exec</classifier>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>