maven--composer---setting.xml(updatepolicy)---mvn install , mvn deploy
场景:
最近再整系统的自动部署流程,由于公司的jar包在svn以及mvn的仓库上都存在,开发人员在开发的过程中都依赖mvn仓库中的Jar
包,在jar上线的时候,配置管理人员把jar 从svn管理的工作目录直接commit到svn的仓库中,同时也执行mvn
deploy命令,把该Jar包deploy 的mvn仓库中。
由于每次执行mvn
deploy的时候,mvn会重新打jar,而在打出的jar包中的META-INF目录下包括一个pom.properties文件,该文件记录的是打
成该jar包的时间,这样导致每次执行mvn
deploy的时候,这个时间都不同,当进行MD5比较的时候,虽然class没有任何变化,但是由于该文件的变化,而导致对同样的代码mvn
deploy成的Jar的md5值不一样
解决办法:
当用mvn install 打出jar 包后,如果需要把该jar原封不动的deploy到mvn仓库中,可以执行如下命令:
mvn deploy:deploy-file -Durl=url -DrepositoryId=repositoryId -Dfile=file -DpomFile=pom.xml -Dversion=1.0
-Durl 是指要deploy到仓库的路径
-DrepositoryId jar 包的repositoryid
-Dfile jar包的具体路径
-DpomFile jar对应的pom路径
-Dversion jar的版本
其实在官网上写的很清楚,如需要查看更加详细的用法,请见官网:
http://maven.apache.org/plugins/maven-deploy-plugin/usage.html
--checkstyle-http://blog.csdn.net/kongxx/article/details/7750015
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>checkstyle</id> <phase>validate</phase> <goals> <goal>check</goal> </goals> <configuration> <failOnViolation>true</failOnViolation> </configuration> </execution> </executions> </plugin>
--------jenkins mvn
http://www.cnblogs.com/zhangchuan210/p/3413811.html
<build>
<directory>target</directory>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<outputDirectory>build</outputDirectory>
<testOutputDirectory>build/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
Look in your settings.xml
(or, possibly your project's parent or corporate parent POM) for the <repositories>
element. It will look something like the below.
<repositories>
<repository>
<id>central</id>
<url>http://gotoNexus</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</releases>
</repository>
</repositories>
Note the <updatePolicy>
element. The example tells Maven to contact the remote repo (Nexus in my case, Maven Central if you're not using your own remote repo) any time Maven needs to retrieve a snapshot artifact during a build, checking to see if there's a newer copy. The metadata is required for this. If there is a newer copy Maven downloads it to your local repo.
In the example, for releases, the policy is daily
so it will check during your first build of the day. never
is also a valid option, as described in Maven settings docs.
Plugins are resolved separately. You may have repositories configured for those as well, with different update policies if desired.
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://gotoNexus</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
Someone else mentioned the -o
option. If you use that, Maven runs in "offline" mode. It knows it has a local repo only, and it won't contact the remote repo to refresh the artifacts no matter what update policies you use.
maven--composer---setting.xml(updatepolicy)---mvn install , mvn deploy的更多相关文章
- Maven配置文件setting.xml详解
注:本文来源于:大话JAVA的那些事 <Maven配置文件setting.xml详解> <?xml version="1.0" encoding="UT ...
- Maven学习笔记—私服(包含maven的setting.xml配置)
为什么要用远程仓库(私服) 如果没有私服,我们所需的所有构件都需要通过maven的中央仓库和第三方的maven仓库下载到本地,而一个团队中的所有人都重复的从maven仓库下载构件,这样就加大了中央仓库 ...
- maven的setting.xml文件中只配置本地仓库路径的方法
maven的setting.xml文件中只配置本地仓库路径的方法 即:settings标签下只有一个 localRepository标签,其他全部注释掉即可 <?xml version=&quo ...
- Maven之setting.xml配置文件详解
setting.xml配置文件 maven的配置文件settings.xml存在于两个地方: 1.安装的地方:${M2_HOME}/conf/settings.xml 2.用户的目录:${user.h ...
- Maven可用setting.xml
最简单的可用阿里镜像配置 <?xml version="1.0" encoding="UTF-8"?> <settings> <l ...
- 【maven】 maven的setting.xml文件的详解
1 Maven的安装 安装Maven之前要确保已经安装好了jdk,并且配置好了环境变量JAVA_HOME.具体安装步骤如下: 从apache网上下载maven项目的压缩包.下载地址为:ht ...
- Maven 的setting.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Soft ...
- maven配置文件setting.xml字段注释
maven的配置文件为settings.xml,在下面路径中可以找到这个文件,分别为: $M2_HOME/conf/settings.xml:全局设置,在maven的安装目录下: ${user.hom ...
- Maven系列--setting.xml 配置详解
文件存放位置 全局配置: ${M2_HOME}/conf/settings.xml 用户配置: ${user.home}/.m2/settings.xml note:用户配置优先于全局配置.${use ...
随机推荐
- http://www.cnblogs.com/yjmyzz/p/3941043.html
http://www.cnblogs.com/yjmyzz/p/3941043.html
- 最大子序列和 HDOJ 1003 Max Sum
题目传送门 题意:求MCS(最大连续子序列和)及两个端点分析:第一种办法:dp[i] = max (dp[i-1] + a[i], a[i]) 可以不开数组,用一个sum表示前i个数字的MCS,其实是 ...
- BZOJ3834 : [Poi2014]Solar Panels
问题相当于找到一个最大的k满足在$[x_1,x_2]$,$[y_1,y_2]$中都有k的倍数 等价于$\frac{x_2}{k}>\frac{x_1-1}{k}$且$\frac{y_2}{k}& ...
- word统计章节字数
只有我这么无聊了..写论文的时候发现每次想看这个章节的字数统计时,还需要全选然后再看字数统计,太麻烦了.所以想着用宏写个能直接查看选定章节的字数统计. 具体方法如下: 建立宏:视图--宏--录制宏-- ...
- 【BZOJ】1901: Zju2112 Dynamic Rankings(区间第k小+树状数组套主席树)
http://www.lydsy.com/JudgeOnline/problem.php?id=1901 首先还是吐槽时间,我在zoj交无限tle啊!!!!!!!!我一直以为是程序错了啊啊啊啊啊啊. ...
- [BZOJ 4436][Cerc2015]Kernel Knights
[Cerc2015]Kernel Knights Time Limit: 2 Sec Memory Limit: 512 MBSubmit: 5 Solved: 4[Submit][Status][D ...
- ccc2016
连炸两题,身败名裂. 看来不拍暴力就会die. A题 滑动窗口或什么前缀和二分之类的就行了. #include<cstdio> #include<cstring> #inclu ...
- SSH全注解开发
web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&quo ...
- [转载]从GetSafeHwnd()和GetSafeHandle()分析句柄和指针
GetSafeHwnd()和GetSafeHandle()的主要区别: 1.使用者不同: (1)窗体使用: GetSafeHwnd()用于获取窗体的安全句柄(即HWND),有了HWND我们就可以方便的 ...
- android之listview
首先建立res/layout/data_list.xml: 代码如下: <?xml version="1.0" encoding="utf-8"?> ...