初学maven,遇到不少问题,记录下来,呵呵,依然是备忘兼共享。
一. The pulgin 'org.apache.maven.plugins:
maven-archetype-plugin' does 
not exist or valid version could be found
    安装官方标准的安装方式(http://maven.apache.org/download.html#Installation)安装完毕,运行mvn --version没有问题。
    然后按照"maven in 5 minutes"(http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html) 的第一个例子,执行
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
    结果报错:
    The pulgin 'org.apache.maven.plugins:
maven-archetype-plugin' does 
not exist or valid version could be found
    ......
    google了一下发现解决方案,原来是网络配置的问题,如果使用代理上网必须修改maven的配置文件加入相应的代理信息。
    打开文件 maven/conf/settings.xml,找到<proxies>,将原来注释掉的<proxy>打开,修改相应的信息即可。
    注意:
    1.)<host>iproxy-sh.cn.ao.ericsson.se</host> 这里不要用"http://"开头,否则会无法连接
    2. ) 如果用户名、密码不需要,可以删除<username><password>,设置为空也行。
二. artifactory私服安装问题
    对于单机来说,maven从远程仓库取jar包等资源是完全合理的。但是如果一个team甚至一个公司,每个人的maven都从远程仓库取,那么花在文件下载上的时间就太多了,而且完全没有必要。因此设置一个开发团队共享的Maven2的私服就必不可少了。
    Maven2的私服,当然首选artifactory。
    跑到artifactory的官网,down下来最新的1.30-beta1,安装非常简单,windows下一个bat文件直接启动。之后修改maven配置,加入
 <repositories>  
     <repository>  
         <id>central</id>  
         <url>http://localhost:8081/artifactory/repo</url>  
         <snapshots>  
             <enabled>false</enabled>  
         </snapshots>  
     </repository>  
     <repository>  
         <id>snapshots</id>  
         <url>http://localhost:8081/artifactory/repo</url>  
         <releases>  
             <enabled>false</enabled>  
         </releases>  
     </repository>  
 </repositories>  
 <pluginRepositories>  
     <pluginRepository>  
         <id>central</id>  
         <url>http://localhost:8081/artifactory/plugins-releases</url>  
         <snapshots>  
             <enabled>false</enabled>  
         </snapshots>  
     </pluginRepository>  
     <pluginRepository>  
         <id>snapshots</id>  
         <url>http://localhost:8081/artifactory/plugins-snapshots</url>  
         <releases>  
             <enabled>false</enabled>  
         </releases>  
     </pluginRepository>  
 </pluginRepositories>
    但是发现执行maven命令时,maven完全没有从私服上取文件,还是到默认的maven官网去取了。反复修改都不行,最后发现问题可能出现在artifactory上:登录artifactory的控制台后,点Virtual Repositories --》 repo 后直接报错,页面抛ArrayIndexOutOfBoundsException!看url是http://localhost:8081/artifactory/repo/,这个不就是上面配置的地址吗?都抛异常了,让maven怎么取文件,找到问题了,虽然莫名其妙,试着删除后重新安装还是这个错误。晕倒,不清楚哪里出的问题,更不知该怎么改。看看版本是beta1,而且下载数量只有几十,想想可能是新版本的bug。
    换成1.2.5final,一切都正常了。
    我想应该是artifactory 1.3.0-beta1的bug吧。
三.
maven的路径变量M2_REPO
     使用mvn eclipse:eclipse命令生成eclipse project后,在eclipse中impot进来,编译出错,原来是maven使用到一个名为“
M2_REPO”的路径变量。
     google了一下,
eclipse中设置变量M2_REPO的方式是:
        Window -> Preferences -> Java -> Build Path -> Classpath Variables,NewName 填写"M2_REPO",路径为你的本地的maven类库地址.
设置后重新编译顺利通过,这样导入eclipse项目就完成了。