我有一个 Dropwizard/AngularJS 网站。我的 Assets 由根目录上的 AssetsBundle 提供:
public void initialize(Bootstrap<WebsiteConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
...
}
我想在/services 上提供我的 REST 端点:
public void run(WebsiteConfiguration configuration, Environment environment) throws Exception {
environment.jersey().setUrlPattern("/service");
...
}
根据我在其他地方看到的文档和答案,这似乎应该可行。然而,我刚刚尝试了一下,/service 上的所有内容都返回 404。当我通过调试器深入研究应用程序时,似乎是因为请求是通过 AssetServlet 而不是通过 Jersey 进行的。
我错过了什么吗?有没有一种好方法可以在根目录上为我的前端提供服务,并在子路径上提供 REST 服务?
最佳答案
前段时间我也被这个问题困扰过。对我有帮助的是将这些行添加到 app.yml
配置文件中:
server:
type: simple
rootPath: '/rest/*'
applicationContextPath: /
关于java - Assets 目录内的 Dropwizard 服务目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31148681/