Maven使用总结

1、pom.xml文件中添加新的库

在中央仓库找不到你想要的jar的时候,可以在pom.xml中添加附加的库,语法如下

    <repositories>
        <repository>
            <id>java.net</id>
            <url>https://repository.jboss.org/nexus/content/groups/public/</url>
        <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases> 
      <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots> 
    </repository>

2、我们在maven install的时候,有些时候其实并不需要顺带执行test动作,这是后可以修改pom文件跳过test步骤

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.13</version>
                
                <configuration>
                    <includes>
                        <include>**/*Tests.java</include>
                    </includes>
                    <skipTests>true</skipTests><!-- 自动跳过test -->
                </configuration>
 </plugin>

3、Failure to transfer xmlpull:xmlpull:jar:1.1.3.1 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact xmlpull:xmlpull:jar:1.1.3.1 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.

出现类似这样的报错,但是maven install 有不管用,可知是本地仓库的缓存(cached)造成,到本地中央仓库的对应目录下把 xxx.lastUpdated文件全部删掉,重新运行maven即可。

或者在用maven时加 -U参数,就可以忽略xxx.lastUpdated.

posted @ 2015-07-19 20:25  mingziday  阅读(1478)  评论(0编辑  收藏  举报