Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BudgetManagementSystem
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王利雷
BudgetManagementSystem
Commits
7d51910a
Commit
7d51910a
authored
May 27, 2019
by
shj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决了数据库连接长时间不使用导致自动关闭的问题,spring定时任务,每小时进行简单数据库交互,这样数据库连接一直保持着
parent
90506276
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
CrawlerService.java
src/main/java/service/impl/CrawlerService.java
+7
-0
spring-tx.xml
src/main/resources/spring-tx.xml
+7
-1
No files found.
src/main/java/service/impl/CrawlerService.java
View file @
7d51910a
...
...
@@ -10,6 +10,7 @@ import org.jsoup.nodes.Element;
import
org.jsoup.select.Elements
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
service.ICrawlerService
;
...
...
@@ -111,4 +112,10 @@ public class CrawlerService implements ICrawlerService {
return
builder
.
toString
();
}
@Scheduled
(
cron
=
"0 0 * * * ?"
)
public
void
MysqlConnection
(){
List
<
Equipment
>
equipmentList
=
equipmentDao
.
selectAll
();
System
.
out
.
println
(
"scheduled..........."
);
}
}
src/main/resources/spring-tx.xml
View file @
7d51910a
...
...
@@ -3,6 +3,7 @@
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop=
"http://www.springframework.org/schema/aop"
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"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
...
...
@@ -13,5 +14,9 @@
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
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>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment