@Resource注入失败问题简析

  • Post author:
  • Post category:其他


项目结构

cff28326245705769a575c9b22c0b44f161.jpg

front和client是两个不同的服务,front依赖client项目,需要在front中注入client的类

声明类:


import com.bluewhale.infra.client.IRestClient;
... ...

@Component("defaultWebServiceRequestHandler")
public class DefaultWebServiceRequestHandler implements BaseHandler {
	protected Logger logger = LoggerFactory.getLogger(this.getClass());

	@Resource(name = "seckillClient")
	private IRestClient seckillClient;
	
	@Resource(name = "objectMapper")
	protected ObjectMapper objectMapper;

	@Resource(name = "restMapping")
	public Map<String, String> restMapping;
    
    ... ...

}

注解类:

import org.springf