Dropwizard 多个资产包冲突

Jer*_*unn 3 java dropwizard

我有几个不同的单页应用程序要嵌入到单个 dropwizard 进程中。如果我注册多个捆绑包,则只有最后一个捆绑包获胜。

bootstrap.addBundle(new AssetsBundle("/web1", "/web1", "index.html));
bootstrap.addBundle(new AssetsBundle("/web2", "/web2", "index.html));
Run Code Online (Sandbox Code Playgroud)

仅提供 web2 服务。如果我反转这些行,则仅提供 web1 服务。

如何正确配置 dropwizard 以便两者都得到服务?

Nam*_*man 6

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

bootstrap.addBundle(new AssetsBundle("/web1", "/web1", "index.html, "asset1"));
bootstrap.addBundle(new AssetsBundle("/web2", "/web2", "index.html, "asset2"));
Run Code Online (Sandbox Code Playgroud)

您正在使用的 AssetsBundle 构造函数的实现如下:

public AssetsBundle(String resourcePath, String uriPath, String indexFile) {
    this(resourcePath, uriPath, indexFile, "assets");
}
Run Code Online (Sandbox Code Playgroud)

因此,您的资源包会被后一个配置覆盖。这在 中以类似的方式解决了dropwizard#499