2015-06-30 29 views
1

我有一个Dropwizard/AngularJS网站。我有我的资产从AssetsBundle服务上的根目录:资产目录内的Dropwizard服务目录

public void initialize(Bootstrap<WebsiteConfiguration> bootstrap) { 
    bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html")); 
    ... 
} 

而且我想担任/服务我的REST端点:

public void run(WebsiteConfiguration configuration, Environment environment) throws Exception { 
    environment.jersey().setUrlPattern("/service"); 
    ... 
} 

基于文件和我在其他地方看到的答案,这似乎应该工作。然而,我只是试了一下,而且/ service上的所有内容都返回了404。当我通过调试器挖掘应用程序时,看起来是因为请求正在通过AssetServlet,而不是通过Jersey。

我错过了什么吗?有没有一种好方法可以在根目录和子路径上的REST服务上为前端服务?

回答

1

我也在前段时间遇到过这个问题。什么帮助我将这些行添加到app.yml配置文件:

server: 
    type: simple 
    rootPath: '/rest/*' 
    applicationContextPath:/
+0

这样做。虽然我研究过它,但在较新版本的Dropwizard中,不需要将类型设置为简单,applicationContextPath和rootPath可与默认服务器一起使用。 –