【发布时间】:2015-02-02 12:15:07
【问题描述】:
我有一个现有的 Spring 应用程序,我自己的上下文被引导 来自数十个 Spring xml 文件。 一个 Grizzly 网络服务器开始发布 Soap 服务。
现在我还想为来自同一个 Grizzly 的 Rest 请求提供服务。 我正在使用 jersey-spring3 但它启动它是自己的,与所需的应用程序上下文分开 applicationContext.xml。
这是创建 Grizzly HttpServer 的代码,其中 Rest 和 Soap 网络服务 已注册:
//rest services
ResourceConfig resourceConfig = new ResourceConfig(
RestService1.class, //these are
RestService2.class //jersey-spring services
);
HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create("http://localhost:8080/rest"), resourceConfig, false);
//soap services
HttpHandler httpHandler = new JaxwsHandler(mySoapWebService, false);
httpServer.getServerConfiguration().addHttpHandler(httpHandler, myPath);
httpServer.start();
我的 Rest 服务(由第二个 Spring 上下文创建)具有来自第一个应用程序上下文的注入依赖项。 这些注射显然不起作用。目前,我正在使用一些 hacky 代码自己手动注入它们。
在现有应用程序中注入 Spring 服务以处理 Rest 请求的正确方法是什么,其中 jersey 重用了现有的上下文?
【问题讨论】:
标签: java spring rest jersey-2.0 grizzly