一、
在子工程配置插件
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.ggj.data_migrater.AwsSchemaLoader</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
先cd 父工程目录下执行
mvn install
再cd 子工程目录下执行
mvn clean package assembly:single
如果直接在子工程执行会报错
Error reading assemblies: No assembly descriptors found
二、记错
我是mac环境配置了2个jdk环境,jdk11和jdk8,mvn打包的时候一直报错
Could not find artifact jdk.tools:jdk.tools:jar:1.7 at specified path /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk.......错误
检查发现/Users/username/.bash_profile JDK配置的是jdk11 但是/etc/profile里面配置的JDK环境变量是jdk8,环境变量冲突了,将.bash_profile 的JDK配置改为jdk8就可以了
三、在父工程控制jdk版本
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>