如果有谁不知道maven,请找度娘。
这里我主要写写使用maven编译java最容易碰到的一些问题。
添加多个远程仓库
jar包在中央仓库没有,需要到其它仓库下载
这里需要在.m2下的settings.xml中增加repository的选项,如
<repository>
<id>atlassian-public</id> <url>https://m2proxy.atlassian.com/repository/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
安装jar包到本地仓库
有时安装到本地仓库比寻找在哪个仓库更加容易
具体方法,参考:http://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-in-maven-project
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
Where: <path-to-file> the path to the file to load
<group-id> the group that the file should be registered under
<artifact-id> the artifact name for the file
<version> the version of the file
<packaging> the packaging of the file e.g. jar
.号中文和英文的区别
[ERROR] Failed to execute goal on project simple-service-webapp: Could not resol
ve dependencies for project com.dds:simple-service-webapp:war:1.0-SNAPSHOT: Fail
ed to collect dependencies at com.googlecode.json-simple:json-simple:jar:1.1。1:
Failed to read artifact descriptor for com.googlecode.json-simple:json-simple:j
ar:1.1。1: Could not transfer artifact com.googlecode.json-simple:json-simple:po
m:1.1。1 from/to atlassian-public (https://m2proxy.atlassian.com/repository/publ
ic): Failed to transfer file: https://m2proxy.atlassian.com/repository/public/co
m/googlecode/json-simple/json-simple/1.1。1/json-simple-1.1。1.pom. Return code
is: 400 , ReasonPhrase:Bad Request. -> [Help 1]
看到中文的simple:json-simple:jar:1.1。1:了吗?就一个句号,我折腾了一个上午,而且在eclipse的console看不出来,是在cmd里面看出来的。
mvn clean之后mvn package会有问题
mvn package之前,可以mvn update一下,参见:
http://stackoverflow.com/questions/15532534/maven-why-after-mvn-clean-i-need-to-execute-maven-update-project-before-m
有时eclipse启动调试功能不生效
这不是eclipse或者tomcat的问题,很有可能就是程序本身有问题,编译或者依赖等,这样就无法调试。
希望这些对大家有帮助。