我正在尝试将 Swagger 与我的 Java REST 服务集成以生成文档。我正在为我的 REST 服务使用 Jersey - guice 和依赖注入。泽西版本是 1.18.2。我正在使用 JBOSS 5.1.2 进行部署。我们的设置与示例项目略有不同。我们将 Jersey 用作侦听器而不是 servlet。我的 web.xml 看起来像这样 -
com.mitchell.services.estimatehelper.ioc.GuiceServletConfig
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我有一个这样的 GuiceServletConfig -
com.mitchell.services.estimatehelper.ioc.GuiceServletConfig
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
AppInjector 如下 -
公共类 AppInjector 扩展 ServletModule{
protected void configureServlets() {
bind(ServletContainer.class).in(Singleton.class);
final Map<String, String> params = new HashMap<String, String>();
params.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
params.put("javax.ws.rs.Application", Application.class.getName());
params.put("jersey.config.server.wadl.disableWadl", "true");
ReflectiveJaxrsScanner scanner = new ReflectiveJaxrsScanner();
scanner.setResourcePackage(getClass().getPackage().getName());
ScannerFactory.setScanner(scanner);
bind(EstimateController.class);
bind(EstimateHelper.class)
.to(EstimateHelperImpl.class);
serve("/*").with(GuiceContainer.class, params);
}
}
当我尝试部署它时,扫描仪会抛出以下异常
2014-12-22 12:58:40,573 错误 [STDERR] (RMI TCP Connection(2)-127.0.0.1) SLF4J: slf4j-api 1.6.x(或更高版本)与此绑定不兼容。2014-12-22 12:58:40,573 错误 [STDERR] (RMI TCP Connection(2)-127.0.0.1) SLF4J:您的绑定是 1.5.5 或更早版本。2014-12-22 12:58:40,573 错误 [STDERR] (RMI TCP Connection(2)-127.0.0.1) SLF4J:将您的绑定升级到版本 1.6.x。或 2.0.x 2014-12-22 12:58:40,573 错误 [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/estimate-helper-rs-1.0.0]] ( RMI TCP Connection(2)-127.0.0.1) 向 com.mitchell.services.estimatehelper.ioc.GuiceServletConfig 类的侦听器实例发送上下文初始化事件的异常 java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg /slf4j/impl/StaticLoggerBinder;在 org.slf4j.LoggerFactory.bind(LoggerFactory.java:
在进一步研究之后,我意识到这个错误是由于 JBoss 使用的日志库引起的。错误是 向类 com.mitchell.services.estimatehelper.ioc.GuiceServletConfig java.lang.NoSuchMethodError 的侦听器实例发送上下文初始化事件的异常:
有什么我可以做的来解决这个问题吗?请帮忙!!
谢谢,SDD