2017-08-24 6 views
1

私は、1つのdropwizardプロセスに埋め込む複数の異なる単一ページアプリケーションを用意しています。複数のバンドルを登録すると、最後のバンドルだけが勝ちます。Dropwizard複数のアセットバンドルの競合

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

web2のみが配信されます。これらの行を逆にすると、web1だけが処理されます。

dropwizardを正しく設定して、両方を提供するにはどうすればよいですか?

答えて

1

は異なり、これらのバンドルを命名してみてください。そのため、あなたの資産バンドルが後者の構成で上書きされます

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

:あなたが使用しているAssetsBundleコンストラクタの

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

実装としてあります。これは同様の方法で のdropwizard#499に解決されました。

+0

はい、ありがとうございます! –

0

ありがとう@nullpointer!実際にも、ドキュメントは、ここでそれをカバー:AssetBundleをアプリケーションに追加され

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

は、それが資産のデフォルトの名前を使用してサーブレットとして登録されています。アプリケーションで複数のAssetBundleインスタンスが必要な場合は、拡張コンストラクタを使用してAssetBundleの一意の名前を指定する必要があります。

修正点は、指摘したとおりにその4番目のパラメータを使用することです。

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