forked from xuxueli/xxl-job
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2、升级jetty版本至9.2;
- Loading branch information
xueli.xue
committed
Apr 28, 2017
1 parent
aa7e5e5
commit a83c21a
Showing
14 changed files
with
340 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.xuxueli</groupId> | ||
<artifactId>xxl-job</artifactId> | ||
<version>1.7.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>xxl-job-executor-springboot-example</artifactId> | ||
<packaging>jar</packaging> | ||
<name>xxl-job-executor-springboot-example</name> | ||
<description>Example executor project for spring boot</description> | ||
|
||
<properties> | ||
<xxl-job.version>1.7.0-SNAPSHOT</xxl-job.version> | ||
<!--<spring-boot.version>1.5.3.RELEASE</spring-boot.version>--> | ||
<spring-boot.version>1.3.8.RELEASE</spring-boot.version> | ||
|
||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.7</java.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<!-- Import dependency management from Spring Boot (依赖管理:继承一些默认的依赖,工程需要依赖的jar包的管理,申明其他dependency的时候就不需要version) --> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>${spring-boot.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-log4j</artifactId> | ||
</dependency> | ||
|
||
<!-- spring-boot-starter-web (提供了对web的支持,包含了spring webmvc和tomcat等web开发的特性) --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- c3p0 --> | ||
<dependency> | ||
<groupId>com.mchange</groupId> | ||
<artifactId>c3p0</artifactId> | ||
<version>0.9.5.2</version> | ||
</dependency> | ||
<!-- mysql-connector --> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.29</version> | ||
</dependency> | ||
|
||
<!-- xxl-job-core --> | ||
<dependency> | ||
<groupId>com.xuxueli</groupId> | ||
<artifactId>xxl-job-core</artifactId> | ||
<version>${xxl-job.version}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<!-- spring-boot-maven-plugin (提供了直接运行项目的插件:如果是通过parent方式继承spring-boot-starter-parent则不用此插件) --> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
xxl-job-executor-springboot-example/src/main/java/com/xxl/job/executor/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.xxl.job.executor; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...cutor-springboot-example/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.xxl.job.executor.core.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.ImportResource; | ||
|
||
|
||
@Configuration | ||
@ImportResource("classpath:applicationcontext-xxl-job.xml") | ||
public class XxlJobConfig { | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...or-springboot-example/src/main/java/com/xxl/job/executor/mvc/handler/IndexController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.xxl.job.executor.mvc.handler; | ||
|
||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
@Controller | ||
@EnableAutoConfiguration | ||
public class IndexController { | ||
|
||
@RequestMapping("/") | ||
@ResponseBody | ||
String index() { | ||
return "xxl job running."; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...ingboot-example/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.xxl.job.executor.service.jobhandler; | ||
|
||
import com.xxl.job.core.biz.model.ReturnT; | ||
import com.xxl.job.core.handler.IJobHandler; | ||
import com.xxl.job.core.handler.annotation.JobHander; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
|
||
/** | ||
* 任务Handler的一个Demo(Bean模式) | ||
* | ||
* 开发步骤: | ||
* 1、继承 “IJobHandler” ; | ||
* 2、装配到Spring,例如加 “@Service” 注解; | ||
* 3、加 “@JobHander” 注解,注解value值为新增任务生成的JobKey的值;多个JobKey用逗号分割; | ||
* | ||
* @author xuxueli 2015-12-19 19:43:36 | ||
*/ | ||
@JobHander(value="demoJobHandler") | ||
@Service | ||
public class DemoJobHandler extends IJobHandler { | ||
private static transient Logger logger = LoggerFactory.getLogger(DemoJobHandler.class); | ||
|
||
@Override | ||
public ReturnT<String> execute(String... params) throws Exception { | ||
logger.info("XXL-JOB, Hello World."); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
logger.info("beat at:{}", i); | ||
TimeUnit.SECONDS.sleep(2); | ||
} | ||
return ReturnT.SUCCESS; | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
xxl-job-executor-springboot-example/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
server.port=8081 |
59 changes: 59 additions & 0 deletions
59
xxl-job-executor-springboot-example/src/main/resources/applicationcontext-xxl-job.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?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}" /> | ||
<property name="appName" value="${xxl.job.executor.appname}" /> | ||
<!-- 执行器注册器 --> | ||
<property name="registHelper" > | ||
<!-- 执行器 "DbRegistHelper" 依赖 "XXL-JOB公共数据源" ;推荐将其抽象为RPC远程服务, 可取消对JDBC的依赖;如不启用执行自动注册功能,也可忽略JDBC配置; --> | ||
<bean class="com.xxl.job.core.registry.impl.DbRegistHelper" > | ||
<!-- XXL-JOB公共数据源 --> | ||
<property name="dataSource" ref="xxlJobDataSource" /> | ||
</bean> | ||
</property> | ||
</bean> | ||
|
||
<!-- ********************************* "XXL-JOB公共数据源" 配置, 仅在启动 "DbRegistHelper" 时才需要, 否则可删除 ********************************* --> | ||
|
||
<!-- 配置03、XXL-JOB公共数据源 --> | ||
<bean id="xxlJobDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> | ||
<property name="driverClass" value="${xxl.job.db.driverClass}" /> | ||
<property name="jdbcUrl" value="${xxl.job.db.url}" /> | ||
<property name="user" value="${xxl.job.db.user}" /> | ||
<property name="password" value="${xxl.job.db.password}" /> | ||
<property name="initialPoolSize" value="3" /> | ||
<property name="minPoolSize" value="2" /> | ||
<property name="maxPoolSize" value="10" /> | ||
<property name="maxIdleTime" value="60" /> | ||
<property name="acquireRetryDelay" value="1000" /> | ||
<property name="acquireRetryAttempts" value="10" /> | ||
<property name="preferredTestQuery" value="SELECT 1" /> | ||
</bean> | ||
|
||
|
||
</beans> |
50 changes: 50 additions & 0 deletions
50
xxl-job-executor-springboot-example/src/main/resources/log4j.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd"> | ||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" threshold="null" debug="null"> | ||
|
||
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> | ||
<param name="Target" value="System.out" /> | ||
<layout class="org.apache.log4j.PatternLayout"> | ||
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-springboot-example [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/> | ||
</layout> | ||
</appender> | ||
|
||
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender"> | ||
<param name="file" value="/data/applogs/xxl-job/xxl-job-executor-springboot-example.log"/> | ||
<param name="append" value="true"/> | ||
<param name="encoding" value="UTF-8"/> | ||
<layout class="org.apache.log4j.PatternLayout"> | ||
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-springboot-example [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/> | ||
</layout> | ||
</appender> | ||
|
||
<appender name="xxl-job" class="com.xxl.job.core.log.XxlJobFileAppender"> | ||
<param name="filePath" value="/data/applogs/xxl-job/jobhandler/"/> | ||
<!--<param name="append" value="true"/>--> | ||
<!--<param name="encoding" value="UTF-8"/>--> | ||
<layout class="org.apache.log4j.PatternLayout"> | ||
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-springboot-example [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/> | ||
</layout> | ||
</appender> | ||
|
||
|
||
<logger name="com.xxl.job.core" additivity="false"> | ||
<level value="INFO" /> | ||
<appender-ref ref="CONSOLE" /> | ||
<appender-ref ref="FILE" /> | ||
<appender-ref ref="xxl-job"/> | ||
</logger> | ||
<logger name="com.xxl.job.executor.service.jobhandler" additivity="false"> | ||
<level value="INFO" /> | ||
<appender-ref ref="CONSOLE" /> | ||
<appender-ref ref="FILE" /> | ||
<appender-ref ref="xxl-job"/> | ||
</logger> | ||
<root> | ||
<level value="INFO" /> | ||
<appender-ref ref="CONSOLE" /> | ||
<appender-ref ref="FILE" /> | ||
<appender-ref ref="xxl-job"/> | ||
</root> | ||
|
||
</log4j:configuration> |
Oops, something went wrong.