Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mall
arch
matrix
Commits
cbb7ac27
Commit
cbb7ac27
authored
Mar 10, 2020
by
haozi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加xxl-job starter
parent
9c075380
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
1 deletions
+133
-1
pom.xml
pom.xml
+13
-1
pom.xml
xxl-job-starter/pom.xml
+39
-0
XxlJobAutoConfiguration.java
xxl-job-starter/src/main/java/com/secoo/mall/xxljob/config/XxlJobAutoConfiguration.java
+78
-0
spring.factories
xxl-job-starter/src/main/resources/META-INF/spring.factories
+3
-0
No files found.
pom.xml
View file @
cbb7ac27
...
...
@@ -25,6 +25,7 @@
<module>
matrix-protocol
</module>
<module>
matrix-datasource
</module>
<module>
rocketmq-starter
</module>
<module>
xxl-job-starter
</module>
</modules>
...
...
@@ -145,7 +146,11 @@
<artifactId>
matrix-protocol-web-starter
</artifactId>
<version>
1.2.12.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
xxl-job-starter
</artifactId>
<version>
1.2.12.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
...
...
@@ -212,6 +217,13 @@
<artifactId>
apollo-client
</artifactId>
<version>
1.4.0
</version>
</dependency>
<!--xxl-job-->
<dependency>
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job-core
</artifactId>
<version>
2.1.2
</version>
</dependency>
</dependencies>
...
...
xxl-job-starter/pom.xml
0 → 100644
View file @
cbb7ac27
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.2.12.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
xxl-job-starter
</artifactId>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-autoconfigure
</artifactId>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>
maven-source-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
xxl-job-starter/src/main/java/com/secoo/mall/xxljob/config/XxlJobAutoConfiguration.java
0 → 100644
View file @
cbb7ac27
package
com
.
secoo
.
mall
.
xxljob
.
config
;
import
com.xxl.job.core.executor.XxlJobExecutor
;
import
com.xxl.job.core.executor.impl.XxlJobSpringExecutor
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.io.File
;
/**
* xxl-job 自动注入初始化
*
* @author zhanghao
* @date 2020-03-1010:02
*/
@Configuration
@ConditionalOnClass
(
XxlJobSpringExecutor
.
class
)
@ConditionalOnProperty
(
prefix
=
"xxl.job"
,
name
=
"enabled"
,
havingValue
=
"true"
)
public
class
XxlJobAutoConfiguration
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
XxlJobAutoConfiguration
.
class
);
/**
* 以下必填
*/
@Value
(
"${spring.application.name}"
)
private
String
appName
;
@Value
(
"${xxl.job.admin.addresses}"
)
private
String
adminAddresses
;
/**
* 以下选填
*/
@Value
(
"${xxl.job.executor.ip:}"
)
private
String
ip
;
@Value
(
"${xxl.job.executor.port:-1}"
)
private
int
port
;
@Value
(
"${xxl.job.accessToken:}"
)
private
String
accessToken
;
@Value
(
"${log.path:/data/logs}"
)
private
String
logPath
;
@Value
(
"${log.max_history:7}"
)
private
int
logRetentionDays
;
@Bean
@ConditionalOnMissingBean
public
XxlJobExecutor
xxlJobExecutor
()
{
LOGGER
.
info
(
">>>>>>>>>>> xxl-job config init."
);
XxlJobExecutor
xxlJobExecutor
=
new
XxlJobSpringExecutor
();
//执行器AppName[选填],为空则关闭自动注册
xxlJobExecutor
.
setAppName
(
appName
);
//执行器注册中心地址[选填],为空则关闭自动注册
xxlJobExecutor
.
setAdminAddresses
(
adminAddresses
);
//执行器IP[选填],为空则自动获取
xxlJobExecutor
.
setIp
(
ip
);
//执行器端口号[选填],小于等于0则自动获取,default 9999
xxlJobExecutor
.
setPort
(
port
);
//访问令牌[选填],非空则进行匹配校验
xxlJobExecutor
.
setAccessToken
(
accessToken
);
//执行器日志路径[选填],为空则使用默认路径
if
(!
logPath
.
contains
(
appName
))
{
//目录加应用名
logPath
+=
File
.
separator
+
appName
;
}
xxlJobExecutor
.
setLogPath
(
logPath
);
//日志保存天数[选填],值大于3时生效
xxlJobExecutor
.
setLogRetentionDays
(
logRetentionDays
);
return
xxlJobExecutor
;
}
}
xxl-job-starter/src/main/resources/META-INF/spring.factories
0 → 100644
View file @
cbb7ac27
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.secoo.mall.xxljob.config.XxlJobAutoConfiguration
\ 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