【发布时间】:2014-09-04 06:13:25
【问题描述】:
我有以下资源类
@Path("/helloworld")
public class HelloWorldResource {
@Inject
private UserAuthorizationRepository userRepository;
@GET
public Response sayHello(@Context UriInfo uriInfo)
以下是我对 UserAuthorizationRepository 的实现
public class UserAuthorizationRepositoryImpl implements UserAuthorizationRepository {
@Inject
private MyUserIdToUserNameTable userIdToUserNameTable;
public String getUserName(Long userId) {
userNameToUserIdTable.getUserName(userId)
}
并且我已将以下活页夹注册到 ResourceConfig
public class RepositoryBinder extends AbstractBinder {
@Override
protected void configure() {
bind(new UserAuthorizationRepositoryImpl()).to(UserAuthorizationRepository.class);
bind(new MyUserIdToUserNameTable()).to(UserIdToUserNameTable.class);
}
在此之后,我的资源类中的 userRepository 绑定正确,但是 UserAuthorizationRepositoryImpl 中的 userIdToUserNameTable 为空。
有人知道原因吗?提前谢谢!
【问题讨论】:
标签: jersey jersey-2.0 hk2