我有这段代码:
@Deployment(name = "default")
public static WebArchive getTestArchive() {
File[] file = Maven.resolver().loadPomFromFile("../pom.xml")
.importCompileAndRuntimeDependencies()
.resolve("org.restlet.gae:org.restlet").withTransitivity().asFile();
System.out.println("FILE>>>>>>>>" + file.toString());
return ShrinkWrap.create(WebArchive.class, "simple.war")
.addClass(org.restlet.ext.servlet.ServerServlet.class)
.setWebXML("web.xml")
.addAsWebInfResource("appengine-web.xml")
.addAsWebInfResource("logging.properties");
}
但是,当测试运行时,它会抛出此错误:
Caused by: org.jboss.shrinkwrap.resolver.api.ResolutionException: Unable to get version for dependency specified by org.restlet.gae:org.restlet:compile, it was not provided in neither <dependencyManagement> nor <dependencies> sections.
at org.jboss.shrinkwrap.resolver.impl.maven.task.ResolveVersionFromMetadataTask.execute(ResolveVersionFromMetadataTask.java:91)
at org.jboss.shrinkwrap.resolver.impl.maven.PomEquippedResolveStageBaseImpl.resolveVersion(PomEquippedResolveStageBaseImpl.java:85)
at org.jboss.shrinkwrap.resolver.impl.maven.ResolveStageBaseImpl.resolveDependency(ResolveStageBaseImpl.java:189)
at org.jboss.shrinkwrap.resolver.impl.maven.ResolveStageBaseImpl.resolveDependency(ResolveStageBaseImpl.java:184)
at org.jboss.shrinkwrap.resolver.impl.maven.ResolveStageBaseImpl.resolve(ResolveStageBaseImpl.java:78)
at org.jboss.shrinkwrap.resolver.impl.maven.ResolveStageBaseImpl.resolve(ResolveStageBaseImpl.java:43)
... 58 more
我的目标是解决POM的所有依赖关系,以便(希望)Restlet arquillian测试能够解决。
答案 0 :(得分:3)
你的错误背后的原因似乎非常明显。您的代码缺少restlet工件的版本号。
应该看起来像:
File[] file = Maven.resolver().loadPomFromFile("../pom.xml")
.importCompileAndRuntimeDependencies()
.resolve("org.restlet.gae:org.restlet:2.3.0") // Notice version number
.withTransitivity().asFile();
或者您可以在<dependencyManagement>
部分中指定版本,但是您的错误消息告诉您,您也忘了它。