Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cash-loan-flow-boss
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
cash-loan-flow-boss
Commits
ba7b99b2
Commit
ba7b99b2
authored
Oct 25, 2019
by
suntao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目启动 sql 执行
parent
e0708d6c
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
453 additions
and
0 deletions
+453
-0
pom.xml
pom.xml
+9
-0
BossInit.java
...va/cn/quantgroup/cashloanflowboss/core/init/BossInit.java
+72
-0
.DS_Store
src/main/resources/.DS_Store
+0
-0
.DS_Store
src/main/resources/sql/.DS_Store
+0
-0
.DS_Store
src/main/resources/sql/bak/.DS_Store
+0
-0
boss_2019-10-22.sql
src/main/resources/sql/bak/boss_2019-10-22.sql
+0
-0
cash_loan_flow_boss_2019-10-24.sql
...main/resources/sql/bak/cash_loan_flow_boss_2019-10-24.sql
+0
-0
base_data.sql
src/main/resources/sql/base_data.sql
+372
-0
No files found.
pom.xml
View file @
ba7b99b2
...
...
@@ -18,7 +18,10 @@
<java.version>
1.8
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
...
...
@@ -145,6 +148,12 @@
<groupId>
org.springframework.retry
</groupId>
<artifactId>
spring-retry
</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/ant/ant -->
<dependency>
<groupId>
ant
</groupId>
<artifactId>
ant
</artifactId>
<version>
1.7.0
</version>
</dependency>
</dependencies>
...
...
src/main/java/cn/quantgroup/cashloanflowboss/core/init/BossInit.java
0 → 100644
View file @
ba7b99b2
package
cn
.
quantgroup
.
cashloanflowboss
.
core
.
init
;
import
org.apache.tools.ant.Project
;
import
org.apache.tools.ant.taskdefs.SQLExec
;
import
org.apache.tools.ant.types.EnumeratedAttribute
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ResourceUtils
;
import
java.io.File
;
/**
* function:
* date: 2019/10/25
*
* @author: suntao
*/
@Component
public
class
BossInit
implements
CommandLineRunner
{
@Value
(
"${data.boss.url}"
)
private
String
url
;
@Value
(
"${data.boss.username}"
)
private
String
username
;
@Value
(
"${data.boss.password}"
)
private
String
password
;
@Value
(
"${spring.datasource.driverClassName}"
)
private
String
driverClassName
;
@Override
public
void
run
(
String
...
strings
)
{
SQLExec
sqlExec
;
try
{
String
[]
sql
=
{
"/sql/base_data.sql"
};
System
.
out
.
println
(
"size: "
+
sql
.
length
);
String
path
=
ResourceUtils
.
getURL
(
"classpath:"
).
getPath
();
System
.
out
.
println
(
path
);
for
(
int
i
=
0
;
i
<
sql
.
length
;
i
++){
String
a
=
sql
[
i
];
System
.
out
.
println
(
a
);
sqlExec
=
new
SQLExec
();
//设置数据库参数
sqlExec
.
setDriver
(
driverClassName
);
sqlExec
.
setUrl
(
url
);
sqlExec
.
setUserid
(
username
);
sqlExec
.
setPassword
(
password
);
sqlExec
.
setEncoding
(
"UTF8"
);
//要执行的脚本
sqlExec
.
setSrc
(
new
File
(
path
+
sql
[
i
]));
//有出错的语句该如何处理
sqlExec
.
setOnerror
((
SQLExec
.
OnError
)(
EnumeratedAttribute
.
getInstance
(
SQLExec
.
OnError
.
class
,
"abort"
)));
sqlExec
.
setPrint
(
true
);
//设置是否输出
sqlExec
.
setProject
(
new
Project
());
// 要指定这个属性,不然会出错
sqlExec
.
execute
();
}
return
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
;
}
}
}
src/main/resources/.DS_Store
0 → 100644
View file @
ba7b99b2
File added
src/main/resources/sql/.DS_Store
0 → 100644
View file @
ba7b99b2
File added
src/main/resources/sql/bak/.DS_Store
0 → 100644
View file @
ba7b99b2
File added
src/main/resources/sql/boss_2019-10-22.sql
→
src/main/resources/sql/b
ak/b
oss_2019-10-22.sql
View file @
ba7b99b2
File moved
src/main/resources/sql/cash_loan_flow_boss_2019-10-24.sql
→
src/main/resources/sql/
bak/
cash_loan_flow_boss_2019-10-24.sql
View file @
ba7b99b2
File moved
src/main/resources/sql/base_data.sql
0 → 100644
View file @
ba7b99b2
This diff is collapsed.
Click to expand it.
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