Java-Maven(十):Maven 项目常用plugins
本文主要总结最近一段时间使用maven时,遇到需要maven plugins的一些简单总结。
1)在Build下重新指定最终打包报名
<build>
<!--最终打包的包名,如果这里不指定,则默认包名为:artifactId-version.jar(com-test-project-1.0-SNAPSHOT.jar)-->
<finalName>The-Test-Pro</finalName>
...
</build>
2)Maven Repository上以外的自定义包引入,以及如何设置才能被打包进来
a)在dependencies下引入lib下的jar
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11-1.5.2.logging</artifactId>
<version>2.11</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/spark-core_2.11-1.5.2.logging-2.11.jar</systemPath>
</dependency>
b)在maven-compiler-plugin配置包时将/lib下的包打包进来
<!--代码编译,指定扩展包在lib下,且打包时将/lib下的包打包进来-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
<compilerArguments>
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
3)通过maven-assembly-plugin设置编译fat包
<!--
在pom中配置了若干依赖,需要将pom中所有的依赖全部打包进一个jar包中,可以选择的方案有maven-assembly-plugin
此时,在Target下会打包一个finalName-jar-with-dependencies.jar,(不指定finalName时:artifactId-version-with-dependencies.jar)
-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.main.Invoker</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
4)使用maven-dependency-plugin拷贝依赖的jar包到/target/lib目录
<!-- 拷贝依赖的jar包到/target/lib目录 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Java-Maven(十):Maven 项目常用plugins的更多相关文章
- 03.基于IDEA+Spring+Maven搭建测试项目--常用dependency
<!--常用的依赖配置--> <!--未展示完整的pom.xml文件内容--> <properties> <java.version>1.8</j ...
- java十五个常用类学习及方法举例
<code class="language-java">import java.util.Scanner; import java.util.Properties; i ...
- java进阶之-Maven,svn,git,maven合拼多个项目
git的使用介绍(写很容易懂得哦) maven合拼多个项目(写得很好哦) MAVEN作用:统一开发规范与工具:统一管理jar包 1.下载MAVEN 下载绿色版的面安装 2.环境配置 eclipse想 ...
- 【项目管理和构建】十分钟教程,eclipse配置maven + 创建maven项目(三)
[项目管理和构建]十分钟教程,eclipse配置maven + 创建maven项目(三) 上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合 ...
- JAVA Eclipse使用Maven构建web项目详解(SSM框架)
tips: 启动项目后,welcome-file的链接即为测试用例 部署maven web项目 Eclipse使用Maven构建web项目详解 pom.xml添加webapp依赖: <depen ...
- IDEA用maven创建springMVC项目和配置(XML配置和Java配置)
1.DEA创建项目 新建一个maven project,并且选择webapp原型. 然后点击next 这里的GroupId和ArtifactID随意填写,但是ArtifactID最好和你的项目一名一样 ...
- 第三章 Maven构建 Java Spring Boot Web项目
3.1 认识Srping Boot Spring Boot是一个框架,是一种全新的编程规范,它的产生简化了对框架的使用,简化了Spring众多的框架中大量的繁琐的配置文件,所以说Spring Bo ...
- springBoot项目常用maven依赖以及依赖说明
springBoot项目常用maven依赖以及依赖说明 1:maven-compiler-plugin <build> <plugins> <!-- 指定maven编译的 ...
- maven新建web项目提示The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
maven新建web项目提示The superclass "javax.servlet.http.HttpServlet" was not found on the Java Bu ...
随机推荐
- oracle in和exists区别
in和exists http://oraclemine.com/sql-exists-vs-in/ https://www.techonthenet.com/oracle/exists.php htt ...
- linux后台运行、关闭、查看后台任务常用命令
一.& 加在一个命令的最后,可以把这个命令放到后台执行,如: [root@bqh-01 ~]# watch -n 3 "sh 1.sh" #每3s在后台执行一次1.sh脚 ...
- LFS7.10——准备Host系统
转载请标明出处:https://www.cnblogs.com/kelamoyujuzhen/articles/9161515.html 实验环境: Host:Windows10 + WMWare W ...
- systemctl 常用操作
以samba为列 systemctl start smb #启动smb服务 systemctl restart smb #重启smb服务 systemctl stop smb ...
- sqlite3入门之sqlite3_mprintf
sqlite3_mprintf sqlite3_mprintf()函数原型: char *sqlite3_mprintf(const char*,...); sqlite3_mprintf()的作用是 ...
- Mysql开启GTID后遇到错误跳过方法
处理方法如下: 一:跳过错误 这个GTID_NEXT的4,是在master 上正常执行的最大id + 1,即Executed_Gtid_Set里面master uuid执行过的最大值 3+ 1 STO ...
- react navtagion 头部有返回按钮 标题不居中解决方法
头部右边写一个隐藏的组件 hederRight:( <View><View> )
- suse12安装详解
1.部署步骤 1.1.启动安装程序 在启动页面上选择Installation,然后按Enter键,这将载入SUSE Linux服务器安装程序并以普通模式安装. 1.2.选择安装语言 Language和 ...
- MySQL将某个数据库下的所有表的存储引擎修改为InnoDB类型语句
如何将mysql数据库中的MyISAM类型表更改为InnoDB类型的表 改单个表 ALTER TABLE TABLENAME ENGINE=InnoDB; ALTER TABLE TABLENAME ...
- Caused by: org.xml.sax.SAXParseException; lineNumber: 64; columnNumber: 27; The entity name must immediately follow the '&' in the entity reference.
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...