也许答案来得有点晚了,但无论如何,我希望它仍然是有价值的你:
你有两个选择,要么从文件中读取存档(可能产生我MVN封装)或创建归档用自己拆封:
选项(1),从@Deployment某处注释称为:
/** maven did it for us .. we just have to read the file */
private static Archive<?> getArchiveFromFile() {
JavaArchive artifact = ShrinkWrap.create(ZipImporter.class, ARCHIVE_NAME).importFrom(ARCHIVE_FILE)
.as(JavaArchive.class);
return artifact;
}
选择(2),我认为有必要从时刻的文件,检查时间,以便有一个选项将其写入文件系统:
/** doing it the hard way ... guess you won't like it as EVERY class plus related stuff needs to be specified */
private static Archive<?> getArchiveManually() {
// creating archive manually
JavaArchive artifact = ShrinkWrap.create(JavaArchive.class, ARCHIVE_NAME)
.addPackage(FooServiceBean.class.getPackage()).addPackage(Foo.class.getPackage())
.addPackage(FooService.class.getPackage()).addAsResource("META-INF/persistence.xml")
.addAsResource("META-INF/beans.xml");
// so we might write it for further inspection
if (WRITE_ARCHIVE) {
artifact.as(ZipExporter.class).exportTo(new File("D:/abc/xyz/tmp/" + ARCHIVE_NAME), true);
}
return artifact;
}
所以你的答案被列入了第二个选项;-)
内