在dubbo的拦截器中,采用@Autowired 自动注入是无效的,例如:
@Autowired
private ShardedJedisPool shardedJedisPool;
在dubbo的拦截器中,可以采取通过setter方式来注入其他的bean,且不要标注注解!
dubbo自己会对这些bean进行注入,例如:
private ShardedJedisPool shardedJedisPool;
//dubbo通过setter方式自动注入
public void setShardedJedisPool(ShardedJedisPool shardedJedisPool) {
this.shardedJedisPool = shardedJedisPool;
}
切记:set注入注意方法名的规范!!!
直接从spring中取也是可以的,例如:
ApplicationContext context = ServiceBean.getSpringContext();
iUturckCache = (IUturckCache) context.getBean(IUturckCache.class);