我是 Jersey 2 的新手。到目前为止,我使用 Jersey 1.x 和 Spring,并希望使用 HK2 实现。
阅读教程后,我写了以下内容:
@ManagedBean
@Path("products")
@Produces({ MediaType.APPLICATION_JSON })
public class ProductResource {
@Inject
ProductManager productManager;
@GET
public GenericResponseData<List<Product>> getProducts(@QueryParam("condition") Condition condition, @QueryParam("keywords") String keywords) {
GenericResponseData<List<Product>> res = new GenericResponseData<List<Product>>();
res.setObject(productManager.getProducts(condition, keywords));
return res;
}
}
@Contract
public interface ProductManager {
public List<Product> getProducts(Condition condition, String keywords);
}
@Service
public class MyProductManager implements ProductManager {
@Override
public List<Product> getProducts(Condition condition, String keywords) {
return null;
}
}
但是我得到以下异常:
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee
怎么了?