第二种方法如下:
package com.hbxf.reupload.utils;
import com.hbxf.reupload.model.ServiceLog;
import com.hbxf.reupload.service.ServiceLogServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class TestSer {
@Autowired
private ServiceLogServiceI serviceLogServiceI;
private static TestSer testSer;
@PostConstruct
public void init(){
testSer = this;
testSer.serviceLogServiceI = this.serviceLogServiceI;
}
public void test(){
ServiceLog serviceLog =(ServiceLog) testSer.serviceLogServiceI.findById("1");
System.out.println(serviceLog.toString());
}
}