Dropwizard / Jersey - 来自配置文件的服务域

时间:2016-07-27 16:50:39

标签: java annotations jersey dropwizard

有没有办法从用于运行Dropwizard服务的yaml配置文件中注入一个字符串@Path注释?

我在guide上找不到任何内容。 感谢

示例:

配置文件:

server:
  applicationConnectors:
  - type: http
    port: 5555
  adminConnectors:
  - type: http
    port: 5556
my-service-domain: /my-service

资源:

@Path("#{my-config.my-service-domain}")
@Produces({"application/json"})
public class MyResource {
...
}

1 个答案:

答案 0 :(得分:0)

对于Dropwizard 0.8.0及更新版本,这是通过以下配置实现的:

applicationContextPath: /
rootPath: /application

其中applicationContextPath是Jetty的Context路径,rootPath是Jersey的。