日期:2014-05-17  浏览次数:20684 次

Spring service调用问题
public class MailTask extends TimerTask {
private static boolean isRunning = false;
@Autowired
KPIManager kpiManager; @SuppressWarnings("deprecation")
public void run() {
if (!isRunning) {
System.out.println("My Mailtask starting....................");
try {
//reciever list
Map<String, RecType> receiver = new LinkedHashMap<String, RecType>();
RecType recType = RecType.t;
//test-Theodore
String receiverId="xxxxxxxxxx";
receiver.put(receiverId, recType);
String sender="yyyyyyyyyyyyyy";
MsgType msgType = MsgType.official;

Date date = new Date();
Calendar cal = new GregorianCalendar();
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.setMinimalDaysInFirstWeek(7);
cal.setTime (date);
String year="";
String week="";
year=String.valueOf(cal.get(Calendar.YEAR));
week= String.valueOf(cal.get(Calendar.WEEK_OF_YEAR));
System.out.println("*******************");
System.out.println(year);
System.out.println(week);
System.out.println("*******************" + kpiManager);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
请教下,为什么系统启动后,无法加载kpiManager,输出总是null,进而无法使用kpiManager方法?

------解决方案--------------------
用@Resource注入
------解决方案--------------------
在接口实现类加@Service
------解决方案--------------------
配置文件怎么写的~
------解决方案--------------------
配置文件,实现类是怎么的?
是否有错误信息?