Maven Multi-module dependency package not found

♀尐吖头ヾ 提交于 2019-11-30 06:51:43

I figured it out. The rest-client-microservice is a Spring Boot project and uses the following plugin:

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

The jar is repackaged and all the packages and classes are put in the BOOT-INF folder. That's the reason why Maven is unable to find them. You can fix this by defining the plugin like this:

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

With this configuration, the Spring Boot Maven Plugin will create 2 JARs: the main one will be the same as a usual Maven project, while the second one will have the classifier appended and be the executable JAR.

For Spring Boot 2, bootRepackage no longer exists as a task. It's replaced by bootJar task. To build two jars using Gradle, I added this to my base module:

jar {
    enabled = true
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!