Pom中的Arquillian ShrinkWrap Maven依赖项 [英] Arquillian ShrinkWrap maven dependencies in pom
问题描述
因此,正如在另一个线程中所建议的那样( Arquillian ShrinkWrap 已切换到托管容器(Jboss AS 7.1),现在错误有所不同
So as suggest in another thread (Arquillian ShrinkWrap have switched to managed container (Jboss AS 7.1) , now the error is different
新的依赖项管理(请参阅以前的原始问题链接以查看)
New dependency managment (see previous link to original question to see )
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId>
<version>2.1.2</version>
<scope>test</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.5.Final</version>
<scope>test</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
然后 我必须添加
<dependency>
<groupId>org.jboss.arquillian.core</groupId>
<artifactId>arquillian-core-api</artifactId>
<version>1.1.4.Final</version>
<scope>test</scope>
</dependency>
因为我有例外
Caused by: java.lang.NoClassDefFoundError: org/jboss/arquillian/core/api/threading/ExecutorService
现在在Jboss本地实例上的部署似乎可以正常工作(只要我有一点时间,我将使用更简单的测试进行测试,但我认为一切都很好) 本质上,问题是将存在于Maven中的jar依赖项(不属于该Maven项目的mistral)添加到已部署的测试中(请参阅此问题的描述(
And now the deploy on local instance of Jboss seems to work fine ( i will test with a simpler test as soon as i have a little time but i think all is fine) Essentially the problem is to add a jar dependencies present in maven (mistral-be which is not part of this maven project) to the deployed test (see description this question(Arquillian ShrinkWrap)). Finally i use this code
String str = "C:\\IntellijProject\\Import***\\import****\\migrazione****-be\\pom.xml";
JavaArchive pomFiles = ShrinkWrap.create(MavenImporter.class)
.loadPomFromFile(str).importBuildOutput().as(JavaArchive.class);
/* https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc#resolution-of-artifacts-defined-in-pom-files */
JavaArchive[] mistral_be = Maven.configureResolver().workOffline().resolve("it.****.mistral:mistral-be:0.1.0").withTransitivity().as(JavaArchive.class);
for (int i = 0; i < mistral_be.length ; i++) {
pomFiles = pomFiles.merge(mistral_be[i]);
}
pomFiles.as(ZipExporter.class).exportTo(new File ("C:\\temp\\res.zip"));
它会生成一个很大的zip文件,仅用于检查结果,但是在尝试将其部署到jboss 7.1.1时
It generate quite a big zip file only to check the result, but while try'n to deploy to jboss 7.1.1
18:46:17,003 INFO [org.jboss.as.repository] (management-handler-thread - 2) JBAS014900: Content added at location C:\jboss\jboss-as-7.1.1.Final\standalone\data\content\bc\b6fd502db2696342419c17a6d2ed82a4176a4e\content
18:46:17,008 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "arquillian-service"
我有一个错误:
org.jboss.arquillian.container.spi.client.container.DeploymentException: Could not deploy to container: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"postImportBE-1.0-SNAPSHOT.jar\".STRUCTURE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"postImportBE-1.0-SNAPSHOT.jar\".STRUCTURE: Failed to process phase STRUCTURE of deployment \"postImportBE-1.0-SNAPSHOT.jar\""}}
我在应用服务器日志中看到的是
As i see in the app server log it is
Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes.
我在压缩文件目录的META_INF中看到很多文件来自mistral-be的传递依赖项,所以问题可能出在此.无论如何,要生成具有有效签名的JAR文件吗?还是我使用错误的方法来解决此问题(以其他方式或类似的方式构造罐子)? 而且我很想知道为什么pom中的依赖项:
I see in the META_INF of the zipped file directory a lot o files coming from transitive dependencies of mistral-be, so the problem could be this. Is there anyway to generate a JAR file with a valid signature? Or may be i am using a wrong aprroach to solve this problem (contruct jar in another way or similar idea)? And i'm curios why the dependencies in pom:
<dependency>
<groupId>it.**.mistral</groupId>
<artifactId>mistral-be</artifactId>
<version>0.1.0</version>
<scope>compile</scope>
</dependency>
不是通过此指令直接导入吗?我错过了什么吗?
is not directly import by this instruction? Did i miss something?
String str = "C:\\IntellijProject\\Import***\\import****\\migrazione****-be\\pom.xml";
JavaArchive pomFiles = ShrinkWrap.create(MavenImporter.class)
.loadPomFromFile(str).importBuildOutput().as(JavaArchive.class);
谢谢
推荐答案
在处理pom依赖项时,我使用WebArchive而不是JavaArchive来包装ShrinkWrap生成的所有必需代码:
When dealing with pom dependencies I use a WebArchive instead of a JavaArchive for wrapping all the required code generated by ShrinkWrap:
String[] mavenLibs = {
"junit:junit:4.8.1"
};
WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");
for (String dependency : mavenLibs) {
war.addAsLibrary(Maven.resolver().resolve(dependency).withTransitivity().asSingle(JavaArchive.class));
}
使用这种机制,我没有您描述的问题.
Using this mecanism I didn't have the issue you described.
这篇关于Pom中的Arquillian ShrinkWrap Maven依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!