Commit 7d51910a by shj

解决了数据库连接长时间不使用导致自动关闭的问题,spring定时任务,每小时进行简单数据库交互,这样数据库连接一直保持着

parent 90506276
...@@ -10,6 +10,7 @@ import org.jsoup.nodes.Element; ...@@ -10,6 +10,7 @@ import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import service.ICrawlerService; import service.ICrawlerService;
...@@ -111,4 +112,10 @@ public class CrawlerService implements ICrawlerService { ...@@ -111,4 +112,10 @@ public class CrawlerService implements ICrawlerService {
return builder.toString(); return builder.toString();
} }
@Scheduled(cron = "0 0 * * * ?")
public void MysqlConnection(){
List<Equipment> equipmentList = equipmentDao.selectAll();
System.out.println("scheduled...........");
}
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/beans/spring-beans.xsd
...@@ -13,5 +14,9 @@ ...@@ -13,5 +14,9 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"> http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<task:annotation-driven/>
<context:component-scan base-package="service.impl"/>
</beans> </beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment