日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Maven问题总结 - 2

發(fā)布時間:2024/9/20 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Maven问题总结 - 2 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Maven問題總結 - 2

一方庫、二方庫、三方庫說明: 一方庫:本工程中的各模塊之前的相互依賴 二方庫:公司內部的依賴庫,一般指公司內部的其他項目發(fā)布的jar包 三方庫:公司之外的開源庫, 比如apache、ibm、google等發(fā)布的依賴 antx eclipse:使用antx生成eclipse工程,方便導入 參考: http://tianya23.blog.51cto.com/1081650/289363 ? http://tianya23.blog.51cto.com/1081650/386891 (1)Maven archetype:generate (2)mkdir src\main\resources,src\test\resources (3)添加parent <parent>
????<groupId>com.alibaba</groupId>
????<artifactId>pampas</artifactId>
????<version>3-RC1</version>
</parent>
由于在3-RC1中的使用做了黑白名單的限制,具體限制為:http://repo.alibaba-inc.com/mvn/wl.txt com.alibaba.*
com.alifi.*
com.taobao.security
com.taobao.util
? 或者 <parent>
????????<groupId>com.alibaba</groupId>
????????<artifactId>pampas</artifactId>
????????<version>1</version>
</parent>
? (4)查詢maven倉庫 http://mvnsearch.org/ 查詢http://repo.alibaba-inc.com/archiva/index.action External倉庫http://svn.alibaba-inc.com/repos/binary/repository/ ? external的地址:http://repo.alibaba-inc.com:9091/external, 它代理了maven的三方庫,http://svn.alibaba-inc.com/repos/binary/repository/
24、跳過單元測試 <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
或使用命令:mvn install -Dmaven.test.skip=true
25、發(fā)布我的jar包到我的remote repository 如何發(fā)布我的jar包到我的remote repository?
你需要在settings.xml中間設置server:?
<servers>?
<server>?
<id>mycompany-repository</id>?
<username>jvanzyl</username>?
<!--
?Default value is ~/.ssh/id_dsa?-->?
<privateKey>/path/to/identity</privateKey>?
<passphrase>my_key_passphrase</passphrase>?
</server>?
</servers>?

然后在pom.xml中設置遠程url:?

<distributionManagement>?
<repository>?
<id>mycompany-repository</id>?
<name>MyCompany Repository</name>?
<url>scp://repository.mycompany.com/repository/maven2</url>?
</repository>?
</distributionManagement>

26、拷貝所有的依賴, mvn dependency:copy-dependencies

會將工程的全部依賴(包括依賴的依賴等)全部拷貝到工程下面的目錄target\dependency下面, 以后就可以直接拷貝到Linux上面了。
27、Maven標準目錄結構 RUL:http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html src/main/java Application/Library sources src/main/resources Application/Library resources src/main/filters Resource filter files src/main/assembly Assembly descriptors src/main/config Configuration files src/main/webapp Web application sources src/test/java Test sources src/test/resources Test resources src/test/filters Test resource filter files src/site Site LICENSE.txt Project's license README.txt Project's readme
28、

Maven內存不夠怎么辦?!

通常是PermSize不夠,用下面參數(shù)一般可解決問題(注意:用上面的apt源安裝的maven,已經(jīng)正確設置了內存大小!):

在安裝目錄下面的bin目錄下面的mvn.bat文件中添加如下內容: set MAVEN_OPTS=-Xms256m -Xmx512m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=128m 參考: http://b2b-doc.alibaba-inc.com/display/opentech/Maven

?

29、Maven運行Junit4 項目中用到了Junit4.x中的一些新特性(通過Annotation定義setUp()@Before,testXXX()@Test)在Eclipse中可以正常run的unit test在Maven2中出來一些奇怪的錯誤,沒有執(zhí)行@Before標記的setUp()方法。

解決步驟:
方案1:
1.在pom中加入surefire-plugin 插件.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>????????
</plugin>

2.在Dependency中加入surefire-junit bundle
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
注意:surefire-junit bundle是一定需要加的,而且加時要注意artifactId,如果是Junit4.7的話artifactId是surefire-junit47. ? 方案2:(推薦方式) ? 添加test依賴 <dependency>?????????????<groupId>com.alibaba.external</groupId>?????????????<artifactId>test.junit</artifactId>?????????????<version>4.8.1</version>?????????</dependency>? 再增加surefire對junit和testng的支持 <plugin>?????????????????<groupId>org.apache.maven.plugins</groupId>?????????????????<artifactId>maven-surefire-plugin</artifactId>?????????????????<configuration>?????????????????????<junitArtifactName>com.alibaba.external:test.junit</junitArtifactName>?????????????????????<testNGArtifactName>com.alibaba.external:test.testng</testNGArtifactName>?????????????????????<excludes>?????????????????????????<exclude>**/IT*.java</exclude>?????????????????????????<exclude>**/*Bean.java</exclude>?????????????????????????<exclude>**/TestHelper.java</exclude>?????????????????????</excludes>?????????????????</configuration>?????????????</plugin>? 結論:建議選用方案2

?

30、Maven版本仲裁原則 ??(1)取路徑最近的 ??(2)路徑相同,取寫在最前面的 如果需要使用某一版本,在dependencyManagement進行聲明 <dependencyManagement>
????<dependencies>
??????<dependency>
????????<artifactId>napoli.client</artifactId>
????????<groupId>com.alibaba.napoli</groupId>
????????<version>1.2.0</version>
??????</dependency>
????</dependencies>
??</dependencyManagement>

31、以debug方式啟動jetty 正常的啟動jetty是這樣的:mvn jetty:run-war?
若想以debug方式來啟動的話,就要用maven_home/bin下的mavenDebug命令,即:?
mvnDebug jetty:run-war?
關于Jetty的更多內容,參考:http://www.ibm.com/developerworks/cn/web/wa-lo-jetty/

32、調試mvn test

執(zhí)行mvn test時查看是什么原因失敗的

? mvn -Dsurefire.useFile=false test 更多參考: http://b2b-doc.alibaba-inc.com/pages/viewpage.action?pageId=29324595
33、下載源代碼 mvn -DdownloadSources=true -Declipse.addVersionToProjectName=true eclipse:eclipse 生成eclipse項目文件,嘗試從repository下載源代碼,并且生成的項目名包含模塊版本(注:如果用公共POM,上述的開關缺省已打開)
34、Eclipse中Maven緩存的問題 在elipse中,默認會緩存之前的依賴內容,當被依賴的內容發(fā)生變化時,重新打包到本地倉庫,此時可能存在報錯的現(xiàn)象,提示一些類無法識別。 非常的惱人,其實只需要Project -> Clean掉重新build即可。
35、

更新當前項目及其 module 的版本

在一個多 module 的 maven 項目中,當項目升級的時候,我們需要修改項目的 version。如果項目中僅有幾個 module,那我們可以手工修改,如果項目中有幾十甚至更多 module 的時候,人肉去修改的話,第一可能會出錯,第二可能會少修改一些 module。使用插件?versions:set?可以很容易地完成這件事情,只要運行如下命令即可: mvn versions:set -DnewVersion=new_version DZone 上有一篇介紹此插件的文章:Managing POM versions

36、

Maven Autoconf使用

autoconf的具體使用參數(shù)參考: http://b2b-doc.alibaba-inc.com/display/opentech/Maven+Autoconf 插件添加到pom.xml <plugin>
????????????????<groupId>com.alibaba.maven.plugins</groupId>
????????????????<artifactId>maven-autoconf-plugin</artifactId>
????????????????<version>0.3-alpha-7</version>
????????????????<executions>
????????????????????<execution>
????????????????????????<id>autoconf</id>
????????????????????????<phase>package</phase>
????????????????????????<goals>
????????????????????????????<goal>autoconf</goal>
????????????????????????</goals>
????????????????????</execution>
????????????????</executions>
????????????????<configuration>
????????????????????<path>${project.build.directory}/${project.build.finalName}.${project.packaging}</path>
????????????????????<!-- -Dxxx=yyy to <xxx>yyy</xxx> -->
????????????????</configuration>
????????????</plugin>

Maven生命周期參考: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

?

?

轉載于:https://blog.51cto.com/tianya23/364072

總結

以上是生活随笔為你收集整理的Maven问题总结 - 2的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。