parent
628a1ac547
commit
7e651b5504
6 changed files with 48 additions and 52 deletions
@ -1,11 +1,46 @@ |
||||
package com.xxl.job.executor.core.config; |
||||
|
||||
import com.xxl.job.core.executor.XxlJobExecutor; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.ComponentScan; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.context.annotation.ImportResource; |
||||
|
||||
|
||||
@Configuration |
||||
@ImportResource("classpath:applicationcontext-xxl-job.xml") |
||||
@ComponentScan(basePackages = "com.xxl.job.executor.service.jobhandler") |
||||
public class XxlJobConfig { |
||||
private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class); |
||||
|
||||
|
||||
@Value("${xxl.job.admin.addresses}") |
||||
private String addresses; |
||||
|
||||
@Value("${xxl.job.executor.appname}") |
||||
private String appname; |
||||
|
||||
@Value("${xxl.job.executor.ip}") |
||||
private String ip; |
||||
|
||||
@Value("${xxl.job.executor.port}") |
||||
private int port; |
||||
|
||||
@Value("${xxl.job.executor.logpath}") |
||||
private String logpath; |
||||
|
||||
|
||||
@Bean(initMethod = "start", destroyMethod = "destroy") |
||||
public XxlJobExecutor xxlJobExecutor() { |
||||
logger.error("------------ xxlJobExecutor -----------"); |
||||
XxlJobExecutor xxlJobExecutor = new XxlJobExecutor(); |
||||
xxlJobExecutor.setIp(ip); |
||||
xxlJobExecutor.setPort(port); |
||||
xxlJobExecutor.setAppName(appname); |
||||
xxlJobExecutor.setAdminAddresses(addresses); |
||||
xxlJobExecutor.setLogPath(logpath); |
||||
return xxlJobExecutor; |
||||
} |
||||
|
||||
} |
@ -1,39 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xmlns:context="http://www.springframework.org/schema/context" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans |
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd |
||||
http://www.springframework.org/schema/context |
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> |
||||
|
||||
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> |
||||
<property name="fileEncoding" value="utf-8" /> |
||||
<property name="locations"> |
||||
<list> |
||||
<value>classpath*:xxl-job-executor.properties</value> |
||||
</list> |
||||
</property> |
||||
</bean> |
||||
|
||||
<!-- ********************************* 基础配置 ********************************* --> |
||||
|
||||
<!-- 配置01、JobHandler 扫描路径 --> |
||||
<context:component-scan base-package="com.xxl.job.executor.service.jobhandler" /> |
||||
|
||||
<!-- 配置02、执行器 --> |
||||
<bean id="xxlJobExecutor" class="com.xxl.job.core.executor.XxlJobExecutor" init-method="start" destroy-method="destroy" > |
||||
<!-- 执行器IP[选填],为空则自动获取 --> |
||||
<property name="ip" value="${xxl.job.executor.ip}" /> |
||||
<!-- 执行器端口号[必须] --> |
||||
<property name="port" value="${xxl.job.executor.port}" /> |
||||
<!-- 执行器AppName[选填],为空则关闭自动注册 --> |
||||
<property name="appName" value="${xxl.job.executor.appname}" /> |
||||
<!-- 执行器注册中心地址[选填],为空则关闭自动注册 --> |
||||
<property name="adminAddresses" value="${xxl.job.admin.addresses}" /> |
||||
<!-- 执行器日志路径[必填] --> |
||||
<property name="logPath" value="${xxl.job.executor.logpath}" /> |
||||
</bean> |
||||
|
||||
|
||||
</beans> |
@ -1,10 +0,0 @@ |
||||
### xxl-job admin address list, such as "http://address" or "http://address01,http://address02" |
||||
xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin |
||||
|
||||
### xxl-job executor address |
||||
xxl.job.executor.appname=xxl-job-executor-example |
||||
xxl.job.executor.ip= |
||||
xxl.job.executor.port=9999 |
||||
|
||||
### xxl-job log path |
||||
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler/ |
Loading…
Reference in new issue