您的位置 首页 java

maven打包成可运行的jar,并指定jdk版本

pom .xml文件添加如下配置即可

<build>

<plugins>

<plugin>

<groupId>org.apache. maven .plugins</groupId>

<artifactId>maven-shade-plugin</artifactId>

<configuration>

<createDependencyReducedPom>true</createDependencyReducedPom>

<filters>

<filter>

<artifact>*:*</artifact>

<excludes>

<exclude>META-INF/*.SF</exclude>

<exclude>META-INF/*.sf</exclude>

<exclude>META-INF/*. DSA </exclude>

<exclude>META-INF/*.dsa</exclude>

<exclude>META-INF/*.RSA</exclude>

<exclude>META-INF/*.rsa</exclude>

<exclude>META-INF/*.EC</exclude>

<exclude>META-INF/*.ec</exclude>

<exclude>META-INF/MSFTSIG.SF</exclude>

<exclude>META-INF/MSFTSIG.RSA</exclude>

</excludes>

</filter>

</filters>

</configuration>

<executions>

<execution>

<phase>package</phase>

<goals>

<goal>shade</goal>

</goals>

<configuration>

<transformers>

<transformer

implementation=”org.apache.maven.plugins.shade.resource.ServicesResourceTransformer” />

<transformer

implementation=”org.apache.maven.plugins.shade.resource.ManifestResourceTransformer”>

<mainClass>com.sys.spring_ks_client.MyApp</mainClass> //启动类

</transformer>

</transformers>

</configuration>

</execution>

</executions>

</plugin>

<! 打包指定java版本–>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<configuration>

<source>1.8</source> //jdk版本

<target>1.8</target>

</configuration>

</plugin>

</plugins>

</build>

文章来源:智云一二三科技

文章标题:maven打包成可运行的jar,并指定jdk版本

文章地址:https://www.zhihuclub.com/196664.shtml

关于作者: 智云科技

热门文章

网站地图