Java 从远程存储库获取/检查依赖性
Maven Dependency插件有一个Java 从远程存储库获取/检查依赖性,java,maven,Java,Maven,Maven Dependency插件有一个get目标,允许您根据repo检查依赖关系。这可能非常有用 使用repoUrl参数 如下面的代码所示,该参数被插件忽略。它将尝试从我的设置文件中的repo获取依赖项 有没有办法检查远程存储库中的依赖关系 jenkins@devops:~$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \ > -DrepoUrl=http://repository.springsou
get
目标,允许您根据repo检查依赖关系。这可能非常有用
使用repoUrl
参数
如下面的代码所示,该参数被插件忽略。它将尝试从我的设置文件中的repo获取依赖项
有没有办法检查远程存储库中的依赖关系
jenkins@devops:~$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \
> -DrepoUrl=http://repository.springsource.com/maven/bundles/external/ \
> -Dartifact=javax.servlet:javax.servlet:2.4.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:get (default-cli) @ standalone-pom ---
Downloading: https://devops.ok:8443/nexus/content/groups/public/javax/servlet/javax.servlet/2.4.0/javax.servlet-2.4.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.221 s
[INFO] Finished at: 2015-12-02T16:33:50+00:00
[INFO] Final Memory: 11M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:get (default-cli) on project standalone-pom: Couldn't download artifact: Failure to find javax.servlet:javax.servlet:jar:2.4.0 in https://devops.ok:8443/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=javax.servlet -DartifactId=javax.servlet -Dversion=2.4.0 -Dpackaging=jar -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=javax.servlet -DartifactId=javax.servlet -Dversion=2.4.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR]
[ERROR] javax.servlet:javax.servlet:jar:2.4.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] nexus (https://devops.ok:8443/nexus/content/groups/public/, releases=true, snapshots=true),
[ERROR] nexus (https://devops.ok:8443/nexus/content/groups/public/, releases=true, snapshots=true)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
jenkins@devops:~$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=http://repository.springsource.com/maven/bundles/external/ -Dartifact=javax.servlet:javax.servlet:2.4.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:get (default-cli) @ standalone-pom ---
Downloading: https://devops.ok:8443/nexus/content/groups/public/javax/servlet/javax.servlet/2.4.0/javax.servlet-2.4.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.245 s
[INFO] Finished at: 2015-12-02T16:38:33+00:00
[INFO] Final Memory: 11M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:get (default-cli) on project standalone-pom: Couldn't download artifact: Failure to find javax.servlet:javax.servlet:jar:2.4.0 in https://devops.ok:8443/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=javax.servlet -DartifactId=javax.servlet -Dversion=2.4.0 -Dpackaging=jar -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=javax.servlet -DartifactId=javax.servlet -Dversion=2.4.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR]
[ERROR] javax.servlet:javax.servlet:jar:2.4.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] nexus (https://devops.ok:8443/nexus/content/groups/public/, releases=true, snapshots=true),
[ERROR] nexus (https://devops.ok:8443/nexus/content/groups/public/, releases=true, snapshots=true)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
jenkins@devops:~$
更新
remoteRepositories
不起作用remoteRepositories
与repoUrl
结合使用,尝试执行更多操作,但也失败了
jenkins@devops:~$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DremoteRepositories=http://repository.springsource.com/maven/bundles/external -Dartifact=javax.servlet:javax.servlet:2.4.0 -DrepoUrl=http://repository.springsource.com/maven/bundles/external/
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:get (default-cli) @ standalone-pom ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.811 s
[INFO] Finished at: 2015-12-02T16:51:10+00:00
[INFO] Final Memory: 7M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:get (default-cli) on project standalone-pom: A type incompatibility occured while executing org.apache.maven.plugins:maven-dependency-plugin:2.1:get: java.lang.String cannot be cast to org.apache.maven.artifact.repository.ArtifactRepository
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-dependency-plugin:2.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/var/lib/jenkins/.m2/repository/org/apache/maven/plugins/maven-dependency-plugin/2.1/maven-dependency-plugin-2.1.jar
jenkins@devops:~$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DremoteRepositories=http://repository.springsource.com/maven/bundles/external -Dartifact=javax.servlet:javax.servlet:2.4.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:get (default-cli) @ standalone-pom ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.860 s
[INFO] Finished at: 2015-12-02T16:55:50+00:00
[INFO] Final Memory: 7M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:get (default-cli) on project standalone-pom: The parameters 'repositoryUrl' for goal org.apache.maven.plugins:maven-dependency-plugin:2.1:get are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
jenkins@devops:~$
您正在使用非常旧版本的
maven依赖插件
。最后一个版本是2.10(而不是2009年的2.1)
最好更新到最新版本。然后,该属性(或用户属性repoUrl
)被弃用。您应改为使用:
$mvn org.apache.maven.plugins:maven依赖插件:2.10:get\
-德雷莫特仓库=http://repository.springsource.com/maven/bundles/external \
-Dartifact=javax.servlet:javax.servlet:2.4.0
但是请注意,如果您的settings.xml
配置了带有*
的,则所有工件请求都会通过它,因此remoteRepositories
将被忽略