java开发新手系列1 --- maven

如果有谁不知道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.11:
 Failed to read artifact descriptor for com.googlecode.json-simple:json-simple:j
ar:1.11: Could not transfer artifact com.googlecode.json-simple:json-simple:po
m:1.11 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.11/json-simple-1.11.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的问题,很有可能就是程序本身有问题,编译或者依赖等,这样就无法调试。

希望这些对大家有帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值