java maven工程打出可执行jar包,在pom.xml中添加如下配置即可标签:java,jar,maven,plugins,apache,org From: https://www.cnblogs.com/loveUworld/p/16985719.html
<build>
<plugins>
<!-- 设置编译版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!--可运行jar包-->
<!--maven-jar-plugin的作用是配置mainClass和指定classpath。-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<!--是否在manifest文件中添加classpath。默认为false。-->
<addClasspath>true</addClasspath>
<!--指定类路径前缀,也就是依赖的jar包所在的文件夹-->
<classpathPrefix>lib/</classpathPrefix>
<!--指定启动类-->
<mainClass>com.cln2ymb.Cln2ymb</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>