0
我寫了一個工作來記錄使用@ Scheduled的東西,所以我在applicationContext.xml中添加了任務:註解驅動。spring任務:註釋驅動使年輕gc頻繁
ActivityCacheJob.java:
@Component
public class ActivityCacheJob {
@Scheduled(cron = "0 * * * * ?")
public void getActivityCacheStatus() {
//dosomething
}
}
的applicationContext.xml:
<task:annotation-driven />
部署之後,我發現年輕的GC時間上漲3至15每分鐘。
然後,我刪除作業,但仍添加任務:在applicationContext.xml中註釋驅動。此問題依然存在。
ActivityCacheJob.java:
//@Component
public class ActivityCacheJob {
//@Scheduled(cron = "0 * * * * ?")
public void getActivityCacheStatus() {
//dosomething
}
}
的applicationContext.xml:
<task:annotation-driven />
所以,我刪除任務:註解驅動,使用XML,這個問題不是不退出。
的applicationContext.xml:
<task:scheduled-tasks>
<task:scheduled ref="activityCacheJob" method="getActivityCacheStatus" cron="0 * * * * ?"/>
</task:scheduled-tasks>
春季版:3.1.1.RELEASE
我的問題是,爲什麼任務:註解驅動使年輕GC奮起?