也許答案來得有點晚了,但無論如何,我希望它仍然是有價值的你:
你有兩個選擇,要麼從文件中讀取存檔(可能產生我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;
}
所以你的答案被列入了第二個選項;-)
內