maven总结
maven使用技巧
使用國內倉庫
找到maven安裝目錄,打開conf/setting。xml文件,找到<mirrors>元素,給它增加一個<mirror>子元素如下:
<mirrors><!--增加的配置:國內maven庫,配置于20150904--><mirror><id>CN</id><name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url><mirrorOf>central</mirrorOf></mirror></mirrors>更詳細的教程看:開源中國 Maven 庫使用幫助
更改本地maven庫的位置
找到maven安裝目錄,打開conf/setting。xml文件,在<settings>元素下,增加一個<localRepository>子元素:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><!--增加的代碼--><localRepository>D:\share\lib\maven\repository</localRepository>出錯處理
pom.xml文件突然出錯
maven項目的pom.xml莫名其妙的出現錯誤(文件上有個叉叉),打開文件,里面的內容沒有任何錯(沒有叉叉)
原因:很可能是某個版本沒有,也就是groupid和artifactid都正確,但是version找不到。
解決辦法一:修改version的值
解決辦法二:可以右鍵 JRE System Library , 進入Properties,然后換一個Execution environment,保存退出,然后再運行maven update就可以了。這個辦法可以消除叉叉,但是不保證能解決問題。
某個依賴無法讀取(can not be read)
Description Resource Path Location Type
Archive for required library: ‘D:/share/lib/maven/repository/junit/junit/4.12/junit-4.12.jar’ in project ‘mocktest’ cannot be read or is not a valid ZIP file mocktest Build path Build Path Problem
原因:很可能是限定了依賴的作用域導致的。比如下面的配置就可能出現上面錯誤:
<dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.8.2</version><scope>test</scope></dependency>解決辦法:把<scope>test</scope>去掉就可以了。
總結
- 上一篇: 搭建Mock Server
- 下一篇: 中望3d快捷键命令大全_史上最全的天正C