插件1:生成可执行jar
Maven Shade Plugin for the simple convenience of making the JAR file executable.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>hello.HelloWorld</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
常用插件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
<artifactId>Plugins</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Plugins</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<!-- 生成的jar包的名称 -->
<finalName>pluginDemo</finalName>
<!-- pluginManagement用于在parent中对插件进行统一配置,然后在子POM中直接引用 如果没有父子POM关系,则直接使用<plugins/>进行插件配置即可。 -->
<pluginManagement>
</pluginManagement>
<!-- 注意:插件可以不指定版本,Maven会自动匹配一个较新的插件进行使用 -->
<plugins>
<!-- 编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<!-- compatible with JVM 1.6 -->
<source>1.6</source>
<target>1.6</target>
<!-- Default value is: ${project.build.sourceEncoding}. -->
<encoding>UTF-8</encoding>
<!-- running the compiler in a separate process -->
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
</configuration>
</plugin>
<!-- 资源文件拷贝插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- Default value is: ${project.build.sourceEncoding}. -->
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- 生成源码包插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<!-- The directory where the generated archive file will be put. Default
value is: ${project.build.directory}. -->
<outputDirectory>${project.build.directory}</outputDirectory>
<!-- Specifies whether or not to include the POM file in the sources-jar.
Default value is: false. -->
<includePom>true</includePom>
<!-- The filename to be used for the generated archive file -->
<finalName>filename-of-generated-jar-file</finalName>
<!-- Specifies whether or not to attach the artifact to the project
Default value is: true. -->
<attach>false</attach>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<!-- generate a stand alone source jar -->
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 测试插件 -->
<!-- JAXWS 插件 -->
<!-- Jetty 插件 -->
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
插件2: 拷贝所有依赖jar包到指定目录中(该插件会到私服下载所有依赖包,包括传递依赖)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependency</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
插件3:与插件1类似,用来指定MANIFEST文件,然后用java -jar xxx.jar运行jar包。由于jar包可能存在很多依赖,因此可以用插件2将所有依赖都下载下来,然后执行。
addClassPath=true设置运行时的类路径,通过classpathPrefix指定依赖包的路径。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<finalName>ccb</finalName>
<archive>
<manifest>
<mainClass>
com.gc.bas.adminconsole.FrameApplication
</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>
./dependency/
</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
分享到:
相关推荐
现在eclipse的社区版都不内置maven插件了,站点在线安装实在是太痛苦了(我装了6个小时),于是急于寻找一种离线安装的办法,可是在网上又找不到对应的m2e包(我用的eclipse4.7),于是我决定将站点下的文件(很多)...
教你如何给eclipse安装maven插件,废话不多说,有图有真相
打开并输入:path= D:/Development/eclipse-JavaEE/eclipse/plugins/maven(请参照上面对应你的 maven 插件) 4. 重启 eclipse,OK,完成了,启动后你打开Window ---> Preferences 会发现一个多了一个选项Maven...
对于eclipse无法在线安装maven插件的解决办法。首先windows配置maven环境,然后在eclipse离线安装maven插件。具体方法可以在我的博客中看到
详细讲解如何为电脑和Eclipse安装maven插件,并且包含maven的电脑安装包和Eclipse的maven插件包,maven插件安装位离线安装,因为在线安装很慢,而且容易出错,原创哦,哈哈
myeclipse maven插件
myeclipse自带有maven插件相难用,而且不能创建maven项目,需要独立安装,即可顺利创建maven项目。 1、删除默认的maven,在该目录下直接搜索maven,删除所有相关的jar和目录。 2、下载maven文件,从...
eclipse的maven插件,下载后 解压至eclipse的dropins目录下,重启即可
在eclipse中,离线安装maven插件,这样就可以配置自己的仓库路径。
在 links 目录下创建一个 maven.txt(名字可以随便取),打开并输入:path=D:\\IDE\\HELIOS\\eclipse\\myplugins\\maven(请参照上面对应你的 maven 插件) 4. 保存关闭 maven.txt,并将后缀改成 maven.link,重启...
eclipse安装maven插件,包含安装步骤。eclipse安装maven插件,包含安装步骤。
Myeclipse10安装maven插件
eclipse maven插件。 因在线安装地址出错,虽然可以去eclipse market中搜到,但有时版本问题,而安装失败。 该文件可以直接copy到eclipse直接子目录下,覆盖原来的plugin和feature文件夹。 不过推荐使用link...
附件以Maven插件为核心,详细的讲述了如何获取插件的信息和插件配置的两种方式。熟练的掌握这些
Maven插件的离线安装方法。可拔性更好,可以随时将插件插上和拔下,非常方便。
低版本的eclipse中不自带maven插件,使用此插件直接安装在eclipse的配置文件中。
文章地址如下:https://blog.csdn.net/sdksdk0/article/details/80678434 自定义maven插件的实现
eclipse安装maven插件时常会出错,将Juno版本安装问题整理出来供大家分享
apache-maven插件,只需要配置相应的私服地址,即可正常使用,具体配置步骤见网上的