1. 程式人生 > >工具類中注入springMVC管理的service

工具類中注入springMVC管理的service

@Component
public class RiskResult {
	private static Logger logger = LoggerFactory.getLogger(RiskResult.class); 
	
    @Autowired  
    private RiskService riskService;
    private static RiskResult riskResult;  
    
    @PostConstruct  
    public void init() {  
    	riskResult = this;  
    	riskResult.riskService = this.riskService;  
  
    }  

注意在類前面要加@Component


,然後就可以呼叫了
List<Record> list = riskResult.riskService.queryRecordAllinfoById(id);

如果要呼叫工具類 直接new就可以



原文轉自:http://blog.csdn.net/p793049488/article/details/37819121