我正在使用Wildfly 10和Java 8.我试图绑定我的服务like here但我仍然收到此错误。我可以看到的唯一区别在于pom.xml依赖项,但2.0-rc1版本是旧的。Jersey 2.22 UnsatisfiedDependencyException
[io.undertow.request] (default task-2) UT005023: Exception handling request to /api/account: javax.servlet.ServletException: A MultiException has 3 exceptions. They are:
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=ICuentaService,parent=CuentaServiceRS,qualifiers={},position=-1,optional=false,self=false,unqualified=null,287721117)
2. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of ar.com.olx.api.rest.CuentaServiceRS errors were found
3. java.lang.IllegalStateException: Unable to perform operation: resolve on ar.com.olx.api.rest.CuentaServiceRS
我的REST API类
@Path("/account")
public class CuentaServiceRS {
@Inject
private ICuentaService cuentaService;
@GET
@Produces(MediaType.APPLICATION_JSON)
public Cuenta getCuenta() {
return cuentaService.getCuentas().get(0);
}
}
的pom.xml
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.2</version>
</dependency>
的web.xml
<servlet>
<servlet-name>altitudeservlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>ar.com.villat.bind.ApplicationJaxRS</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
我的应用JAX-RS类
public class ApplicationJaxRS extends ResourceConfig {
public ApplicationJaxRS(){
register(new CustomBinder());
packages(true, "ar.com.villat");
}
}
最后,我的定制绑定
public class CustomBinder extends AbstractBinder {
@Override
protected void configure() {
bind(ICuentaService.class).to(CuentaServiceImpl.class);
}
}
如果您需要更多的细节,请告诉我
谢谢你的回答和解释。 – Villat