问题描述
我已经在 Jersey 中设置了 Web 服务。我已经能够向所有资源注入一个对象。
public class ApplicationConfig extends ResourceConfig {
private final Logger logger = LogManager.getLogger(ApplicationConfig.class);
public ApplicationConfig() {
packages("com.example.Server");
try {
SampleClass sample = new SampleClass();
register(new AbstractBinder() {
@Override
protected void configure() {
bind(sample).to(SampleClass.class);
}
});
}
catch (sqlException throwables) {
logger.error("Can't initialize API.",throwables);
}
}
}
除了资源之外,我还有一个 Websocket 端点,我也想在其中访问“示例”对象。 @Inject 在这里不起作用。 有没有办法做到这一点?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)