我添加了Swagger到我的Dropwizard服務,而且它工作的很好。Dropwizard Jersey設置URL模式打破Swagger 404?
但是現在,我想添加一個簡單的HTML頁面,並配置從/assets
服務內容,它打破招搖和API 與
404
反應
這是我的代碼資源路徑
public class NumericodeApplication extends Application<NumericodeConfiguration> {
public static void main(final String[] args) throws Exception {
new NumericodeApplication().run(args);
}
@Override
public String getName() {
return "Numericode";
}
@Override
public void initialize(final Bootstrap<NumericodeConfiguration> bootstrap) {
bootstrap.addBundle(new SwaggerBundle<NumericodeConfiguration>() {
@Override
protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(NumericodeConfiguration configuration) {
return configuration.swaggerBundleConfiguration;
}
});
bootstrap.addBundle(new AssetsBundle("/assets", "/", "index.html")); //added this
}
@Override
public void run(final NumericodeConfiguration configuration, final Environment environment) {
environment.jersey().register(new Controller());
environment.jersey().setUrlPattern("/swagger"); //tried this
environment.jersey().setUrlPattern("/api/*"); //added this
}
}
當我嘗試刪除兩個setUrlPattern()方法調用它抱怨
多個servlet地圖路徑/ *:資產[映射:JAVAX_API:空],io.dropwizard.jersey.setup.JerseyServletContainer-2e5b7fba [映射:嵌入式:空]
但是,如果我刪除的資產包揚鞭OK再次工作?
我怎樣才能讓我的索引頁和Swagger在Dropwizard/Jetty上工作。
獎勵積分,如果你能解釋發生了什麼!