maven_build_plugin

Resources插件负责处理项目资源文件并拷贝到输出目录。Maven将main resources和test resources分开,一般main resources关联main source code,而test resources关联test source code。

Resources插件目标有三个:

resources:resources,拷贝main resources到main output directory。它绑定了process-resources生命周期阶段,当执行Compiler:compile插件目标前就会执行此阶段。
resources:testResources,拷贝test resources到test output directory。它绑定了process-test-resources生命周期阶段,当执行surefire:test插件目标前就会执行此阶段。
resources:copy-resources,手动拷贝资源到输出目录

maven-dependency-plugins
1.需要某个特殊的 jar包,但是有不能直接通过maven依赖获取,或者说在其他环境的maven仓库内不存在,那么如何将我们所需要的jar包打入我们的生产jar包中。

2.某个jar包内部包含的文件是我们所需要的,或者是我们希望将它提取出来放入指定的位置 ,那么除了复制粘贴,如何通过maven插件实现呢?

dependency插件我们最常用到的是

dependency:copy

dependency:copy-dependencies:Goal that copies the project dependencies from the repository to a defined location.

dependency:unpack

dependency:unpack-dependencies 这四个
======maven-war-plugin=

org.apache.maven.plugins
maven-war-plugin
2.4

p r o j e c t . a r t i f a c t I d < / w a r N a m e > < w a r S o u r c e E x c l u d e s > n o d e j s / ∗ ∗ < / w a r S o u r c e E x c l u d e s > < w e b R e s o u r c e s > < r e s o u r c e > < f i l t e r i n g > t r u e < / f i l t e r i n g > < d i r e c t o r y > s r c / m a i n / p r o f i l e < / d i r e c t o r y > < t a r g e t P a t h > W E B − I N F < / t a r g e t P a t h > < i n c l u d e s > < i n c l u d e > ∗ ∗ / w e b . x m l < / i n c l u d e > < / i n c l u d e s > < / r e s o u r c e > < r e s o u r c e > < f i l t e r i n g > t r u e < / f i l t e r i n g > < d i r e c t o r y > s r c / m a i n / p r o f i l e / p a g e s < / d i r e c t o r y > < t a r g e t P a t h > p a g e s < / t a r g e t P a t h > < i n c l u d e s > < i n c l u d e > ∗ ∗ < / i n c l u d e > < / i n c l u d e s > < / r e s o u r c e > < / w e b R e s o u r c e s > < w a r S o u r c e D i r e c t o r y > s r c / m a i n / w e b a p p < / w a r S o u r c e D i r e c t o r y > < w e b X m l > s r c / m a i n / w e b a p p / W E B − I N F / w e b . x m l < / w e b X m l > < / c o n f i g u r a t i o n > < / p l u g i n > = = = = = = = = = = = = = = = = = = = = = = = = m a v e n − c o m p i l e r − p l u g i n = = = = = = = = = = = = = = = = = = = = = = = = = = < p l u g i n > < ! − − 指 定 m a v e n 编 译 的 j d k 版 本 , 如 果 不 指 定 , m a v e n 3 默 认 用 j d k 1.5 m a v e n 2 默 认 用 j d k 1.3 − − > < g r o u p I d > o r g . a p a c h e . m a v e n . p l u g i n s < / g r o u p I d > < a r t i f a c t I d > m a v e n − c o m p i l e r − p l u g i n < / a r t i f a c t I d > < v e r s i o n > 3.1 < / v e r s i o n > < c o n f i g u r a t i o n > < ! − − 一 般 而 言 , t a r g e t 与 s o u r c e 是 保 持 一 致 的 , 但 是 , 有 时 候 为 了 让 程 序 能 在 其 他 版 本 的 j d k 中 运 行 ( 对 于 低 版 本 目 标 j d k , 源 代 码 中 不 能 使 用 低 版 本 j d k 中 不 支 持 的 语 法 ) , 会 存 在 t a r g e t 不 同 于 s o u r c e 的 情 况 − − > < s o u r c e > 1.8 < / s o u r c e > < ! − − 源 代 码 使 用 的 J D K 版 本 − − > < t a r g e t > 1.8 < / t a r g e t > < ! − − 需 要 生 成 的 目 标 c l a s s 文 件 的 编 译 版 本 − − > < e n c o d i n g > U T F − 8 < / e n c o d i n g > < ! − − 字 符 集 编 码 − − > < s k i p T e s t s > t r u e < / s k i p T e s t s > < ! − − 跳 过 测 试 − − > < v e r b o s e > t r u e < / v e r b o s e > < s h o w W a r n i n g s > t r u e < / s h o w W a r n i n g s > < f o r k > t r u e < / f o r k > < ! − − 要 使 c o m p i l e r V e r s i o n 标 签 生 效 , 还 需 要 将 f o r k 设 为 t r u e , 用 于 明 确 表 示 编 译 版 本 配 置 的 可 用 − − > < e x e c u t a b l e > < ! − − p a t h − t o − j a v a c − − > < / e x e c u t a b l e > < ! − − 使 用 指 定 的 j a v a c 命 令 , 例 如 : < e x e c u t a b l e > {project.artifactId}</warName> <warSourceExcludes>nodejs/**</warSourceExcludes> <webResources> <resource> <filtering>true</filtering> <directory>src/main/profile</directory> <targetPath>WEB-INF</targetPath> <includes> <include>**/web.xml</include> </includes> </resource> <resource> <filtering>true</filtering> <directory>src/main/profile/pages</directory> <targetPath>pages</targetPath> <includes> <include>**</include> </includes> </resource> </webResources> <warSourceDirectory>src/main/webapp</warSourceDirectory> <webXml>src/main/webapp/WEB-INF/web.xml</webXml> </configuration> </plugin> ========================maven-compiler-plugin========================== <plugin> <!-- 指定maven编译的jdk版本,如果不指定,maven3默认用jdk 1.5 maven2默认用jdk1.3 --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <!-- 一般而言,target与source是保持一致的,但是,有时候为了让程序能在其他版本的jdk中运行(对于低版本目标jdk,源代码中不能使用低版本jdk中不支持的语法),会存在target不同于source的情况 --> <source>1.8</source> <!-- 源代码使用的JDK版本 --> <target>1.8</target> <!-- 需要生成的目标class文件的编译版本 --> <encoding>UTF-8</encoding><!-- 字符集编码 --> <skipTests>true</skipTests><!-- 跳过测试 --> <verbose>true</verbose> <showWarnings>true</showWarnings> <fork>true</fork><!-- 要使compilerVersion标签生效,还需要将fork设为true,用于明确表示编译版本配置的可用 --> <executable><!-- path-to-javac --></executable><!-- 使用指定的javac命令,例如:<executable> project.artifactId</warName><warSourceExcludes>nodejs/</warSourceExcludes><webResources><resource><filtering>true</filtering><directory>src/main/profile</directory><targetPath>WEBINF</targetPath><includes><include>/web.xml</include></includes></resource><resource><filtering>true</filtering><directory>src/main/profile/pages</directory><targetPath>pages</targetPath><includes><include></include></includes></resource></webResources><warSourceDirectory>src/main/webapp</warSourceDirectory><webXml>src/main/webapp/WEBINF/web.xml</webXml></configuration></plugin>========================mavencompilerplugin==========================<plugin><!mavenjdk,,maven3jdk1.5maven2jdk1.3><groupId>org.apache.maven.plugins</groupId><artifactId>mavencompilerplugin</artifactId><version>3.1</version><configuration><!targetsourcejdk(jdk使jdk)targetsource><source>1.8</source><!使JDK><target>1.8</target><!class><encoding>UTF8</encoding><!><skipTests>true</skipTests><!><verbose>true</verbose><showWarnings>true</showWarnings><fork>true</fork><!使compilerVersionforktrue><executable><!pathtojavac></executable><!使javac<executable>{JAVA_1_4_HOME}/bin/javac -->
1.3
128m
512m
-verbose -bootclasspath KaTeX parse error: Undefined control sequence: \lib at position 12: {java.home}\̲l̲i̲b̲\rt.jar</compil…{pom.basedir}/lib/ojdbc8.jar

<build>
	<plugins>
	 <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <useUniqueVersions>false</useUniqueVersions>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>cn.xk.dp.weixin.Driver</mainClass>
                    </manifest>
                    <manifestEntries>  <!--将ojdbc8-1.0.jar写进MANIFEST.MF文件中的Class-Path-->
			           <Class-Path>lib/ojdbc8-1.0.jar</Class-Path>
		            </manifestEntries> 
                </archive>
                <excludes>   <!--排除用于测试的日志配置资源文件-->
                    <exclude>log4j2-test.xml</exclude>
                </excludes>
            </configuration>
       </plugin>
	<plugin>  <!--在打包阶段将依赖的jar包导出到lib目录下-->
	  <groupId>org.apache.maven.plugins</groupId>
	  <artifactId>maven-dependency-plugin</artifactId>
	  <executions>
	    <execution>
		<id>copy-dependencies</id>
                    <phase>package</phase>
		<goals>
		  <goal>copy-dependencies</goal>
		</goals>
		<configuration>
		  <type>jar</type>
		  <includeTypes>jar</includeTypes>
          <outputDirectory>${project.build.directory}/lib</outputDirectory>
		</configuration>
	    </execution>
	  </executions>
     </plugin>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值