繁体   English   中英

Dropwizard多个资产捆绑冲突

[英]Dropwizard Multiple Asset Bundles Conflict

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

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"));

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

public AssetsBundle(String resourcePath, String uriPath, String indexFile) {
    this(resourcePath, uriPath, indexFile, "assets");
}

因此,您的资产捆绑将被后一种配置覆盖。 dropwizard#499中以类似的方式解决了这个问题。

谢谢@nullpointer! 实际上,甚至文档都在这里进行了介绍:

http://www.dropwizard.io/0.9.1/docs/manual/core.html

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

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

bootstrap.addBundle(new AssetsBundle("/web1", "/web1", "index.html, "asset1"));
bootstrap.addBundle(new AssetsBundle("/web2", "/web2", "index.html, "asset2"));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM