Java Dropwizard多个资产包冲突

Java Dropwizard多个资产包冲突,java,dropwizard,Java,Dropwizard,我在一个dropwizard进程中嵌入了两个不同的单页应用程序。如果我注册了多个bundle,则只有最后一个bundle获胜 bootstrap.addBundle(new AssetsBundle("/web1", "/web1", "index.html)); bootstrap.addBundle(new AssetsBundle("/web2", "/web2", "index.html)); 只提供web2。如果我颠倒这些行,则只提供web1 如何正确配置dropwizard,以便两

我在一个dropwizard进程中嵌入了两个不同的单页应用程序。如果我注册了多个bundle,则只有最后一个bundle获胜

bootstrap.addBundle(new AssetsBundle("/web1", "/web1", "index.html));
bootstrap.addBundle(new AssetsBundle("/web2", "/web2", "index.html));
只提供web2。如果我颠倒这些行,则只提供web1


如何正确配置dropwizard,以便两者都可以使用?

尝试以不同的方式命名这些捆绑包:

bootstrap.addBundle(new AssetsBundle("/web1", "/web1", "index.html, "asset1"));
bootstrap.addBundle(new AssetsBundle("/web2", "/web2", "index.html, "asset2"));
bootstrap.addBundle(new AssetsBundle("/web1", "/web1", "index.html, "asset1"));
bootstrap.addBundle(new AssetsBundle("/web2", "/web2", "index.html, "asset2"));
您正在使用的AssetsBundle构造函数的实现如下所示:

public AssetsBundle(String resourcePath, String uriPath, String indexFile) {
    this(resourcePath, uriPath, indexFile, "assets");
}
因此,您的资产包将被后一种配置覆盖。这是以类似的方式解决的
中。

谢谢@nullpointer!事实上,就连文件也在这里提到了这一点:

将AssetBundle添加到应用程序时,它将使用默认的资产名称注册为servlet。如果应用程序需要有多个AssetBundle实例,则应使用扩展构造函数为AssetBundle指定唯一的名称

解决方法是使用您指出的第四个参数