專案版本升級用了relase版本,但是釋出以後,依賴的jar包在編譯以後的lib目錄還是舊版本。
原因是snapshot版本每次釋出都會更新遠端和本地倉庫的檔案,但是release版本會先在本地版本庫中檢查,如果存在就使用本地版本庫的,沒有才拉取遠端倉庫的。同樣的,release版本的程式碼在遠端倉庫也是不會更新的。
那麼當發現relase版本的依賴有問題時該怎麼辦呢?
下面是可以解決問題的幾個方案。
-
將版本號升級。 新的版本號會在遠端倉庫生成新的檔案,本地倉庫會重新下載。
-
將本地和遠端倉庫中的舊版本刪除,重新打包上去。
-
更改settings.xml,將updatePolicy改為always。
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
複製程式碼
- maven執行打包命令的時候加上
-U
命令強制下載所有依賴的jar包
$ mvn clean install
……
[INFO] --- maven-dependency-plugin:2.1:copy-dependencies (copy-dependencies) @ demo ---
[INFO] aopalliance-1.0.jar already exists in destination.
[INFO] c3p0-0.9.1.1.jar already exists in destination.
[INFO] cglib-3.2.5.jar already exists in destination.
[INFO] druid-1.0.31.jar already exists in destination.
[INFO] fastjson-1.2.31.jar already exists in destination.
[INFO] jackson-annotations-2.5.0.jar already exists in destination.
[INFO] jackson-core-2.5.0.jar already exists in destination.
[INFO] jackson-databind-2.5.0.jar already exists in destination.
[INFO] commons-beanutils-1.8.3.jar already exists in destination.
[INFO] commons-codec-1.2.jar already exists in destination.
[INFO] commons-collections-3.2.1.jar already exists in destination.
[INFO] commons-fileupload-1.3.1.jar already exists in destination.
[INFO] commons-httpclient-3.1.jar already exists in destination.
[INFO] commons-io-2.2.jar already exists in destination.
[INFO] commons-lang-2.5.jar already exists in destination.
[INFO] commons-logging-1.1.3.jar already exists in destination.
[INFO] jstl-1.2.jar already exists in destination.
[INFO] log4j-1.2.17.jar already exists in destination.
[INFO] mysql-connector-java-5.1.40.jar already exists in destination.
[INFO] thumbnailator-0.4.8.jar already exists in destination.
[INFO] ehcache-core-2.6.8.jar already exists in destination.
[INFO] ezmorph-1.0.6.jar already exists in destination.
[INFO] json-lib-2.4-jdk15.jar already exists in destination.
[INFO] ant-1.9.6.jar already exists in destination.
[INFO] ant-launcher-1.9.6.jar already exists in destination.
[INFO] httpclient-4.5.7.jar already exists in destination.
[INFO] httpcore-4.4.11.jar already exists in destination.
[INFO] shiro-core-1.2.2.jar already exists in destination.
[INFO] shiro-web-1.2.2.jar already exists in destination.
[INFO] aspectjweaver-1.8.9.jar already exists in destination.
[INFO] mybatis-3.2.3.jar already exists in destination.
[INFO] mybatis-spring-1.3.1.jar already exists in destination.
[INFO] asm-5.2.jar already exists in destination.
[INFO] lombok-1.16.16.jar already exists in destination.
[INFO] quartz-2.2.1.jar already exists in destination.
[INFO] slf4j-api-1.7.20.jar already exists in destination.
[INFO] slf4j-log4j12-1.7.20.jar already exists in destination.
[INFO] spring-aop-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-beans-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-context-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-context-support-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-core-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-expression-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-jdbc-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-test-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-tx-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-web-4.2.5.RELEASE.jar already exists in destination.
[INFO] spring-webmvc-4.2.5.RELEASE.jar already exists in destination.
[INFO] standard-1.1.2.jar already exists in destination.
……
複製程式碼