我正在尝试使用Wildfly Swarm将带有静态HTML页面的webapp文件夹添加到JAXRSArchive。但不幸的是,它没有成功。我怎样才能做到这一点?

最佳答案

将所有静态文件复制到src/main/webapp中,并在主方法中添加调用staticContenet,如下所示

public static void main(String... args) throws Exception {
    Swarm container = new Swarm();
    JAXRSArchive jaxrsDeployment = ShrinkWrap.create(JAXRSArchive.class);
    jaxrsDeployment.addAsLibrary(container.createDefaultDeployment());
    jaxrsDeployment.addAllDependencies();
    jaxrsDeployment.staticContent();
    container.start();
    container.deploy(jaxrsDeployment);

10-06 10:04