I want to redeploy a web application and find it cannot compile successfully. The error is that some classes in the “com.solomon/solomon-am-client” dependency cannot be found.
After some investigation, I find the root cause is that, the version “1.0-SNAPSHOT” of “com.solomon/solomon-am-client” used by this project is updated and the classes used in the project are removed from its code.
The following is the final working solution:
Copy the previous working version “solomon-am-client.jar/solomon-am-client.pom/solomon-model.jar/solomon-model.pom” files from the local repository directory to host directory. Rename them to “solomon-am-client-ags.jar/solomon-am-client-ags.pom/solomon-model-ags.jar/solomon-model-ags.pom”.
Update the “artifactId” to “solomon-model-ags/solomon-am-client-ags” in both pom files and the “solomon-model-ags” dependency in the “solomon-am-client-ags.pom” file. Keep everything else intact.
Run the following command to deploy the “solomon-model-ags/solomon-am-client-ags” artifacts into the remote repisitory:
# From: https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.htmlmvn deploy:deploy-file -DpomFile=/home/gang/solomon-model-ags.pom \ -Dfile=/home/gang/solomon-model-ags.jar \ -DrepositoryId=360buy-snapshots \ -Durl=http://artifactory.360buy-develop.com/libs-snapshots-local
mvn deploy:deploy-file -DpomFile=/home/gang/solomon-am-client-ags.pom \ -Dfile=/home/gang/solomon-am-client-ags.jar \ -DrepositoryId=360buy-snapshots \ -Durl=http://artifactory.360buy-develop.com/libs-snapshots-local
# The result of the 2 commands should succeed which means the 2 jars have been added into the remote Maven repository.
Update the “pom.xml” of the project which used the “solomon-am-client” dependency:
Note the “artifactId” is updated from “solomon-am-client” to “solomon-am-client-ags”.
Now build the project again and it can finish successfully.
The knowledge here is that: for any “xxx-SNAPSHOT” dependency version, it always uses the latest one. If the latest SNAPSHOT version intruduced some incompatible code comparing to the previous SNAPSHOT version, the problem happens, just like what I described above. So for serious dependency can be used by other project, using version without SNAPSHOT is a good idea.