使用Sping Cloud 生成jar的过程,一直提示找不到依赖关系,但是在idea中启动并没有问题。处理方法如下:
1/ parent 模块的pom文件中添加
<build>
<plugins>
<plugin>
<!-- The plugin rewrites your manifest -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中 -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
2/common 模块(被依赖模块)的pom文件中添加
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中 -->
</goals>
<!--可以生成不含依赖包的不可执行Jar包 -->
<configuration> <classifier>exec</classifier> </configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
3/业务模块(依赖其他模块) 的pom文件中添加
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>