xueli.xue 9 lat temu
rodzic
commit
3e6851a2d4
30 zmienionych plików z 1031 dodań i 1 usunięć
  1. 2 0
      pom.xml
  2. 163 0
      xxl-job-admin/pom.xml
  3. 16 0
      xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java
  4. 13 0
      xxl-job-admin/src/main/java/com/xxl/service/ITriggerService.java
  5. 30 0
      xxl-job-admin/src/main/java/com/xxl/service/impl/TriggerServiceImpl.java
  6. 38 0
      xxl-job-admin/src/main/resources/applicationcontext-base.xml
  7. 43 0
      xxl-job-admin/src/main/resources/applicationcontext-database.xml
  8. 34 0
      xxl-job-admin/src/main/resources/applicationcontext-trigger.xml
  9. 44 0
      xxl-job-admin/src/main/resources/applicationcontext-tx.xml
  10. 10 0
      xxl-job-admin/src/main/resources/freemarker.properties
  11. 2 0
      xxl-job-admin/src/main/resources/freemarker.variables.properties
  12. 4 0
      xxl-job-admin/src/main/resources/jdbc.properties
  13. 10 0
      xxl-job-admin/src/main/resources/log4j.properties
  14. 50 0
      xxl-job-admin/src/main/resources/springmvc-context.xml
  15. 55 0
      xxl-job-admin/src/main/webapp/WEB-INF/web.xml
  16. 5 1
      xxl-job-core/pom.xml
  17. 163 0
      xxl-job-demo/pom.xml
  18. 16 0
      xxl-job-demo/src/main/java/com/xxl/controller/IndexController.java
  19. 13 0
      xxl-job-demo/src/main/java/com/xxl/service/ITriggerService.java
  20. 30 0
      xxl-job-demo/src/main/java/com/xxl/service/impl/TriggerServiceImpl.java
  21. 38 0
      xxl-job-demo/src/main/resources/applicationcontext-base.xml
  22. 43 0
      xxl-job-demo/src/main/resources/applicationcontext-database.xml
  23. 34 0
      xxl-job-demo/src/main/resources/applicationcontext-trigger.xml
  24. 44 0
      xxl-job-demo/src/main/resources/applicationcontext-tx.xml
  25. 10 0
      xxl-job-demo/src/main/resources/freemarker.properties
  26. 2 0
      xxl-job-demo/src/main/resources/freemarker.variables.properties
  27. 4 0
      xxl-job-demo/src/main/resources/jdbc.properties
  28. 10 0
      xxl-job-demo/src/main/resources/log4j.properties
  29. 50 0
      xxl-job-demo/src/main/resources/springmvc-context.xml
  30. 55 0
      xxl-job-demo/src/main/webapp/WEB-INF/web.xml

+ 2 - 0
pom.xml Wyświetl plik

@@ -7,6 +7,8 @@
7 7
 	<packaging>pom</packaging>
8 8
 	<modules>
9 9
 		<module>xxl-job-core</module>
10
+		<module>xxl-job-demo</module>
11
+		<module>xxl-job-admin</module>
10 12
 	</modules>
11 13
 
12 14
 	<build>

+ 163 - 0
xxl-job-admin/pom.xml Wyświetl plik

@@ -0,0 +1,163 @@
1
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+	<modelVersion>4.0.0</modelVersion>
4
+	<parent>
5
+		<groupId>com.xxl</groupId>
6
+		<artifactId>xxl-job</artifactId>
7
+		<version>0.0.1-SNAPSHOT</version>
8
+	</parent>
9
+	<artifactId>xxl-job-admin</artifactId>
10
+	<packaging>war</packaging>
11
+	
12
+	<properties>
13
+		<spring.version>3.2.14.RELEASE</spring.version>
14
+	</properties>
15
+
16
+	<dependencies>
17
+		<!-- springframe start -->
18
+		<dependency>
19
+			<groupId>org.springframework</groupId>
20
+			<artifactId>spring-webmvc</artifactId>
21
+			<version>${spring.version}</version>
22
+		</dependency>
23
+		<dependency>
24
+			<groupId>org.springframework</groupId>
25
+			<artifactId>spring-context-support</artifactId>
26
+			<version>${spring.version}</version>
27
+		</dependency>
28
+		<dependency>
29
+			<groupId>org.springframework</groupId>
30
+			<artifactId>spring-orm</artifactId>
31
+			<version>${spring.version}</version>
32
+		</dependency>
33
+		<dependency>
34
+			<groupId>org.springframework</groupId>
35
+			<artifactId>spring-test</artifactId>
36
+			<version>${spring.version}</version>
37
+		</dependency>
38
+		<!-- springframe end -->
39
+		<!-- aspectjweaver (support spring aop) -->
40
+		<dependency>
41
+			<groupId>org.aspectj</groupId>
42
+			<artifactId>aspectjweaver</artifactId>
43
+			<version>1.8.7</version>
44
+		</dependency>
45
+		<!-- jackson (support spring json) -->
46
+		<dependency>
47
+			<groupId>org.codehaus.jackson</groupId>
48
+			<artifactId>jackson-mapper-asl</artifactId>
49
+			<version>1.9.13</version>
50
+		</dependency>
51
+
52
+		<!-- slf4j -->
53
+		<dependency>
54
+			<groupId>org.slf4j</groupId>
55
+			<artifactId>slf4j-log4j12</artifactId>
56
+			<version>1.7.5</version>
57
+		</dependency>
58
+
59
+		<!-- freemarker -->
60
+		<dependency>
61
+			<groupId>org.freemarker</groupId>
62
+			<artifactId>freemarker</artifactId>
63
+			<version>2.3.20</version>
64
+		</dependency>
65
+
66
+		<!-- commons-beanutils -->
67
+		<dependency>
68
+			<groupId>commons-beanutils</groupId>
69
+			<artifactId>commons-beanutils</artifactId>
70
+			<version>1.9.2</version>
71
+		</dependency>
72
+		<!-- commons-lang -->
73
+		<dependency>
74
+			<groupId>commons-lang</groupId>
75
+			<artifactId>commons-lang</artifactId>
76
+			<version>2.6</version>
77
+		</dependency>
78
+
79
+		<!-- servlet -->
80
+		<dependency>
81
+			<groupId>javax.servlet</groupId>
82
+			<artifactId>servlet-api</artifactId>
83
+			<version>2.5</version>
84
+			<scope>provided</scope>
85
+		</dependency>
86
+		<dependency>
87
+			<groupId>javax.servlet.jsp</groupId>
88
+			<artifactId>jsp-api</artifactId>
89
+			<version>2.1</version>
90
+			<scope>provided</scope>
91
+		</dependency>
92
+
93
+		<!-- junit -->
94
+		<dependency>
95
+			<groupId>junit</groupId>
96
+			<artifactId>junit</artifactId>
97
+			<version>4.11</version>
98
+			<scope>test</scope>
99
+		</dependency>
100
+
101
+		<!-- c3p0 -->
102
+		<dependency>
103
+			<groupId>c3p0</groupId>
104
+			<artifactId>c3p0</artifactId>
105
+			<version>0.9.1.2</version>
106
+		</dependency>
107
+		<!-- mybatis-spring -->
108
+		<dependency>
109
+			<groupId>org.mybatis</groupId>
110
+			<artifactId>mybatis-spring</artifactId>
111
+			<version>1.2.2</version>
112
+		</dependency>
113
+		<dependency>
114
+			<groupId>org.mybatis</groupId>
115
+			<artifactId>mybatis</artifactId>
116
+			<version>3.2.8</version>
117
+		</dependency>
118
+		<!-- mysql-connector -->
119
+		<dependency>
120
+			<groupId>mysql</groupId>
121
+			<artifactId>mysql-connector-java</artifactId>
122
+			<version>5.1.29</version>
123
+		</dependency>
124
+
125
+		<!-- quartz :quartz-2.2.1/c3p0-0.9.1.1/slf4j-api-1.6.6 -->
126
+		<dependency>
127
+			<groupId>org.quartz-scheduler</groupId>
128
+			<artifactId>quartz</artifactId>
129
+			<version>2.2.1</version>
130
+		</dependency>
131
+		<!-- xxl-mq-core -->
132
+		<dependency>
133
+			<groupId>com.xxl</groupId>
134
+			<artifactId>xxl-job-core</artifactId>
135
+			<version>0.0.1-SNAPSHOT</version>
136
+		</dependency>
137
+
138
+	</dependencies>
139
+
140
+	<build>
141
+		<plugins>
142
+			<plugin>
143
+				<groupId>org.apache.maven.plugins</groupId>
144
+				<artifactId>maven-compiler-plugin</artifactId>
145
+				<version>3.1</version>
146
+				<configuration>
147
+					<source>1.6</source>
148
+					<target>1.6</target>
149
+					<encoding>UTF8</encoding>
150
+				</configuration>
151
+			</plugin>
152
+			<plugin>
153
+				<groupId>org.apache.maven.plugins</groupId>
154
+				<artifactId>maven-war-plugin</artifactId>
155
+				<version>2.2</version>
156
+				<configuration>
157
+					<archiveClasses>true</archiveClasses>
158
+				</configuration>
159
+			</plugin>
160
+		</plugins>
161
+	</build>
162
+
163
+</project>

+ 16 - 0
xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java Wyświetl plik

@@ -0,0 +1,16 @@
1
+package com.xxl.controller;
2
+
3
+import org.springframework.stereotype.Controller;
4
+import org.springframework.web.bind.annotation.RequestMapping;
5
+import org.springframework.web.bind.annotation.ResponseBody;
6
+
7
+@Controller
8
+@RequestMapping("/")
9
+public class IndexController {
10
+
11
+	@RequestMapping("")
12
+	@ResponseBody
13
+	private String index() {
14
+		return "hehe";
15
+	}
16
+}

+ 13 - 0
xxl-job-admin/src/main/java/com/xxl/service/ITriggerService.java Wyświetl plik

@@ -0,0 +1,13 @@
1
+package com.xxl.service;
2
+
3
+/**
4
+ * Trigger Service
5
+ * @author xuxueli
6
+ */
7
+public interface ITriggerService {
8
+	
9
+	/**
10
+	 * 全站静态化
11
+	 */
12
+	public void generateNetHtml();
13
+}

+ 30 - 0
xxl-job-admin/src/main/java/com/xxl/service/impl/TriggerServiceImpl.java Wyświetl plik

@@ -0,0 +1,30 @@
1
+package com.xxl.service.impl;
2
+
3
+import org.slf4j.Logger;
4
+import org.slf4j.LoggerFactory;
5
+import org.springframework.stereotype.Service;
6
+
7
+import com.xxl.service.ITriggerService;
8
+
9
+/**
10
+ * Trigger Service
11
+ * @author xuxueli
12
+ */
13
+@Service("triggerService")
14
+public class TriggerServiceImpl implements ITriggerService {
15
+	private static transient Logger logger = LoggerFactory.getLogger(TriggerServiceImpl.class);
16
+	
17
+	
18
+	/**
19
+	 * 全站静态化
20
+	 */
21
+	public void generateNetHtml() {
22
+		long start = System.currentTimeMillis();
23
+		logger.info("全站静态化... start:{}", start);
24
+		
25
+			
26
+		long end = System.currentTimeMillis();
27
+		logger.info("全站静态化... end:{}, cost:{}", end, end - start);
28
+	}
29
+	
30
+}

+ 38 - 0
xxl-job-admin/src/main/resources/applicationcontext-base.xml Wyświetl plik

@@ -0,0 +1,38 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
+	xmlns:util="http://www.springframework.org/schema/util"
5
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
6
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
+           http://www.springframework.org/schema/context
8
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd
9
+           http://www.springframework.org/schema/util 
10
+           http://www.springframework.org/schema/util/spring-util.xsd">
11
+
12
+	<context:annotation-config />
13
+	<context:component-scan base-package="com.xxl.service.impl, com.xxl.dao.impl" />
14
+
15
+	<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
16
+		<property name="templateLoaderPath" value="/WEB-INF/template/" />
17
+		<property name="freemarkerSettings">
18
+			<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
19
+				<property name="location" value="classpath:freemarker.properties" />
20
+			</bean>
21
+		</property>
22
+		<property name="freemarkerVariables">
23
+			<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
24
+				<property name="location" value="classpath:freemarker.variables.properties" />
25
+			</bean>
26
+		</property>
27
+	</bean>
28
+
29
+	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
30
+		<property name="fileEncoding" value="utf-8" />
31
+		<property name="locations">
32
+			<list>
33
+				<value>classpath*:jdbc.properties</value>
34
+			</list>
35
+		</property>
36
+	</bean>
37
+
38
+</beans>

+ 43 - 0
xxl-job-admin/src/main/resources/applicationcontext-database.xml Wyświetl plik

@@ -0,0 +1,43 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
+	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5
+	xsi:schemaLocation="
6
+		http://www.springframework.org/schema/beans 
7
+		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
8
+		http://www.springframework.org/schema/context 
9
+		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
10
+		http://www.springframework.org/schema/aop 
11
+		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
12
+		http://www.springframework.org/schema/tx 
13
+		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
14
+		
15
+	<context:annotation-config />
16
+	<context:component-scan base-package="com.xxl.service.impl, com.xxl.dao.impl" />
17
+
18
+	<!-- c3p0:Main数据源  -->
19
+	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">  
20
+	    <property name="driverClass" value="${c3p0.driverClass}" />  
21
+	    <property name="jdbcUrl" value="${c3p0.url}" />  
22
+	    <property name="user" value="${c3p0.user}" />  
23
+	    <property name="password" value="${c3p0.password}" />  
24
+	    <property name="initialPoolSize" value="3" />  
25
+	    <property name="minPoolSize" value="2" />  
26
+	    <property name="maxPoolSize" value="10" />  
27
+	    <property name="maxIdleTime" value="60" />
28
+	    <property name="acquireRetryDelay" value="1000" />
29
+	    <property name="acquireRetryAttempts" value="10" />
30
+	    <property name="preferredTestQuery" value="SELECT 1" />
31
+	</bean>
32
+	
33
+	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
34
+		<property name="dataSource" ref="dataSource" />
35
+		<property name="mapperLocations" value="classpath*:com/xxl/core/model/mapper/*.xml"/>
36
+	</bean>
37
+    
38
+    <!-- Template在Junit测试的时候,必须使用scope="prototype",原因未知 -->
39
+    <bean id="sqlSessionTemplate"  class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">  
40
+          <constructor-arg index="0" ref="sqlSessionFactory" />  
41
+    </bean> 
42
+	
43
+</beans>

+ 34 - 0
xxl-job-admin/src/main/resources/applicationcontext-trigger.xml Wyświetl plik

@@ -0,0 +1,34 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
+	xmlns:util="http://www.springframework.org/schema/util"
5
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
6
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
+           http://www.springframework.org/schema/context
8
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd
9
+           http://www.springframework.org/schema/util 
10
+           http://www.springframework.org/schema/util/spring-util.xsd">
11
+
12
+	<!-- 全站静态化:Job Detail -->
13
+	<bean id="generateNetHtmlJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
14
+		<property name="targetObject" ref="triggerService" />
15
+		<property name="targetMethod" value="generateNetHtml" />
16
+		<property name="concurrent" value="false" />
17
+	</bean>
18
+	
19
+	<!-- 全站静态化:Cron Trigger (quartz-2.x的配置) -->
20
+	<bean id="generateNetHtmlTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
21
+		<property name="jobDetail" ref="generateNetHtmlJobDetail" />
22
+		<property name="cronExpression" value="0 0/5 * * * ? *" />
23
+	</bean>
24
+	
25
+	<!-- 启动触发器的配置开始 -->
26
+	<bean name="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
27
+		<property name="triggers">
28
+			<list>
29
+				<ref bean="generateNetHtmlTrigger" />
30
+			</list>
31
+		</property>
32
+	</bean>
33
+
34
+</beans>

+ 44 - 0
xxl-job-admin/src/main/resources/applicationcontext-tx.xml Wyświetl plik

@@ -0,0 +1,44 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
+	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5
+	xsi:schemaLocation="
6
+		http://www.springframework.org/schema/beans 
7
+		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
8
+		http://www.springframework.org/schema/context 
9
+		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
10
+		http://www.springframework.org/schema/aop 
11
+		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
12
+		http://www.springframework.org/schema/tx 
13
+		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
14
+
15
+    <!-- 事务管理器(声明式事务) -->
16
+	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
17
+		<property name="dataSource" ref="dataSource" />
18
+	</bean>
19
+      
20
+	<!-- 启动事务注解(方式1:注解方式) -->
21
+	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
22
+	
23
+	<!-- 事务通知(方式2:XML事务管理) -->
24
+	<tx:advice id="txAdvice" transaction-manager="transactionManager">
25
+		<tx:attributes>
26
+			<tx:method name="detail*" propagation="SUPPORTS" />
27
+			<tx:method name="visit*" propagation="SUPPORTS" />
28
+			<tx:method name="get*" propagation="SUPPORTS" />
29
+			<tx:method name="find*" propagation="SUPPORTS" />
30
+			<tx:method name="check*" propagation="SUPPORTS" />
31
+			<tx:method name="list*" propagation="SUPPORTS" />
32
+			<tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
33
+		</tx:attributes>
34
+	</tx:advice>
35
+
36
+	<!-- AOP配置 -->
37
+	<aop:config>
38
+		<!-- 定义一个切入点 -->
39
+		<aop:pointcut id="txoperation" expression="execution(* com.xxl.service.imp.*.*(..))" />
40
+		<!-- 切入点事务通知 -->
41
+		<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
42
+	</aop:config>
43
+	
44
+</beans>

+ 10 - 0
xxl-job-admin/src/main/resources/freemarker.properties Wyświetl plik

@@ -0,0 +1,10 @@
1
+template_update_delay=0
2
+default_encoding=UTF-8
3
+output_encoding=UTF-8
4
+locale=zh_CN
5
+number_format=0.##########
6
+date_format=yyyy-MM-dd
7
+time_format=HH:mm:ss
8
+datetime_format=yyyy-MM-dd HH:mm:s
9
+classic_compatible=true
10
+template_exception_handler=ignore

+ 2 - 0
xxl-job-admin/src/main/resources/freemarker.variables.properties Wyświetl plik

@@ -0,0 +1,2 @@
1
+# 静态文件地址 
2
+static_url=https://www.baidu.com/

+ 4 - 0
xxl-job-admin/src/main/resources/jdbc.properties Wyświetl plik

@@ -0,0 +1,4 @@
1
+c3p0.driverClass=com.mysql.jdbc.Driver
2
+c3p0.url=jdbc:mysql://localhost:3306/test?Unicode=true&amp;characterEncoding=UTF-8
3
+c3p0.user=root
4
+c3p0.password=root_pwd

+ 10 - 0
xxl-job-admin/src/main/resources/log4j.properties Wyświetl plik

@@ -0,0 +1,10 @@
1
+log4j.rootLogger=info,console
2
+
3
+log4j.appender.console=org.apache.log4j.ConsoleAppender
4
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
5
+log4j.appender.console.layout.ConversionPattern=%d - xxl-job-admin - %p [%c] - <%m>%n
6
+
7
+log4j.appender.logFile=org.apache.log4j.DailyRollingFileAppender
8
+log4j.appender.logFile.File=${catalina.base}/logs/xxl-job-admin.log
9
+log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
10
+log4j.appender.logFile.layout.ConversionPattern=%d - xxl-job-admin - %p [%c] - <%m>%n

+ 50 - 0
xxl-job-admin/src/main/resources/springmvc-context.xml Wyświetl plik

@@ -0,0 +1,50 @@
1
+<?xml version="1.0" encoding="UTF-8"?> 
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+    xmlns:aop="http://www.springframework.org/schema/aop" 
4
+    xmlns:context="http://www.springframework.org/schema/context" 
5
+    xmlns:p="http://www.springframework.org/schema/p" 
6
+    xmlns:tx="http://www.springframework.org/schema/tx"
7
+    xmlns:mvc="http://www.springframework.org/schema/mvc"
8
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9
+    xsi:schemaLocation="  
10
+		http://www.springframework.org/schema/beans 
11
+		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
12
+		http://www.springframework.org/schema/context 
13
+		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
14
+		http://www.springframework.org/schema/aop 
15
+		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
16
+		http://www.springframework.org/schema/tx 
17
+		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
18
+		http://www.springframework.org/schema/mvc
19
+		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
20
+
21
+	<description>Spring-web MVC配置</description>
22
+	
23
+	<mvc:annotation-driven /> 
24
+	<context:component-scan base-package="com.xxl.controller" />
25
+	
26
+	<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
27
+	<mvc:resources mapping="/static/**" location="/static/" />
28
+	
29
+	<bean id="viewResolver"	class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
30
+		<property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />	<!-- 解析视图模板类 -->
31
+		<property name="prefix" value="" />								<!-- 模板前后缀,指定html页面为模板 -->
32
+		<property name="suffix" value=".ftl" />
33
+		<property name="contentType" value="text/html;charset=UTF-8" />	<!-- 模板输出内容编码 (此处应与defaultEncoding保持一致) -->
34
+		<property name="exposeSpringMacroHelpers" value="true" />		<!-- 访问Request/Session宏助手 -->
35
+		<property name="exposeRequestAttributes" value="true" />		<!-- 允许访问Request属性,默认为false -->
36
+		<property name="exposeSessionAttributes" value="true" />		<!-- 允许访问Session属性,默认为false -->
37
+		<property name="requestContextAttribute" value="request" />		<!-- 将HttpServletRequest的属性存放到request这个变量中 -->
38
+		<property name="cache" value="true" />
39
+		<property name="order" value="0" />
40
+	</bean>
41
+	
42
+	<!-- <mvc:interceptors>
43
+		<mvc:interceptor>
44
+			<mvc:mapping path="/**"/>
45
+			<bean class="com.xxl.controller.interceptor.PermissionInterceptor"/>
46
+		</mvc:interceptor>
47
+	</mvc:interceptors>
48
+ 	<bean id="exceptionResolver" class="com.xxl.controller.resolver.WebExceptionResolver" /> -->
49
+	
50
+</beans>

+ 55 - 0
xxl-job-admin/src/main/webapp/WEB-INF/web.xml Wyświetl plik

@@ -0,0 +1,55 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
+	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5
+	id="WebApp_ID" version="2.5">
6
+	<display-name>xxl-job-admin</display-name>
7
+
8
+	<context-param>
9
+		<param-name>contextConfigLocation</param-name>
10
+		<param-value>classpath*:applicationcontext-*.xml</param-value>
11
+	</context-param>
12
+
13
+	<listener>
14
+		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
15
+	</listener>
16
+	<listener>
17
+		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
18
+	</listener>
19
+
20
+	<filter>
21
+		<filter-name>encodingFilter</filter-name>
22
+		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
23
+		<init-param>
24
+			<param-name>encoding</param-name>
25
+			<param-value>UTF-8</param-value>
26
+		</init-param>
27
+		<init-param>
28
+			<param-name>forceEncoding</param-name>
29
+			<param-value>true</param-value>
30
+		</init-param>
31
+	</filter>
32
+	<filter-mapping>
33
+		<filter-name>encodingFilter</filter-name>
34
+		<url-pattern>/*</url-pattern>
35
+	</filter-mapping>
36
+
37
+	<servlet>
38
+		<servlet-name>springmvc</servlet-name>
39
+		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
40
+		<init-param>
41
+			<param-name>contextConfigLocation</param-name>
42
+			<param-value>classpath*:springmvc-context.xml</param-value>
43
+		</init-param>
44
+		<load-on-startup>1</load-on-startup>
45
+	</servlet>
46
+	<servlet-mapping>
47
+		<servlet-name>springmvc</servlet-name>
48
+		<url-pattern>/</url-pattern>
49
+	</servlet-mapping>
50
+
51
+	<welcome-file-list>
52
+		<welcome-file>index.html</welcome-file>
53
+	</welcome-file-list>
54
+
55
+</web-app>

+ 5 - 1
xxl-job-core/pom.xml Wyświetl plik

@@ -7,5 +7,9 @@
7 7
 		<version>0.0.1-SNAPSHOT</version>
8 8
 	</parent>
9 9
 	<artifactId>xxl-job-core</artifactId>
10
-	<version>0.0.1-SNAPSHOT</version>
10
+	<packaging>war</packaging>
11
+	
12
+	<dependencies>
13
+	</dependencies>
14
+	
11 15
 </project>

+ 163 - 0
xxl-job-demo/pom.xml Wyświetl plik

@@ -0,0 +1,163 @@
1
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+	<modelVersion>4.0.0</modelVersion>
4
+	<parent>
5
+		<groupId>com.xxl</groupId>
6
+		<artifactId>xxl-job</artifactId>
7
+		<version>0.0.1-SNAPSHOT</version>
8
+	</parent>
9
+	<artifactId>xxl-job-demo</artifactId>
10
+	<packaging>war</packaging>
11
+
12
+	<properties>
13
+		<spring.version>3.2.14.RELEASE</spring.version>
14
+	</properties>
15
+
16
+	<dependencies>
17
+		<!-- springframe start -->
18
+		<dependency>
19
+			<groupId>org.springframework</groupId>
20
+			<artifactId>spring-webmvc</artifactId>
21
+			<version>${spring.version}</version>
22
+		</dependency>
23
+		<dependency>
24
+			<groupId>org.springframework</groupId>
25
+			<artifactId>spring-context-support</artifactId>
26
+			<version>${spring.version}</version>
27
+		</dependency>
28
+		<dependency>
29
+			<groupId>org.springframework</groupId>
30
+			<artifactId>spring-orm</artifactId>
31
+			<version>${spring.version}</version>
32
+		</dependency>
33
+		<dependency>
34
+			<groupId>org.springframework</groupId>
35
+			<artifactId>spring-test</artifactId>
36
+			<version>${spring.version}</version>
37
+		</dependency>
38
+		<!-- springframe end -->
39
+		<!-- aspectjweaver (support spring aop) -->
40
+		<dependency>
41
+			<groupId>org.aspectj</groupId>
42
+			<artifactId>aspectjweaver</artifactId>
43
+			<version>1.8.7</version>
44
+		</dependency>
45
+		<!-- jackson (support spring json) -->
46
+		<dependency>
47
+			<groupId>org.codehaus.jackson</groupId>
48
+			<artifactId>jackson-mapper-asl</artifactId>
49
+			<version>1.9.13</version>
50
+		</dependency>
51
+
52
+		<!-- slf4j -->
53
+		<dependency>
54
+			<groupId>org.slf4j</groupId>
55
+			<artifactId>slf4j-log4j12</artifactId>
56
+			<version>1.7.5</version>
57
+		</dependency>
58
+
59
+		<!-- freemarker -->
60
+		<dependency>
61
+			<groupId>org.freemarker</groupId>
62
+			<artifactId>freemarker</artifactId>
63
+			<version>2.3.20</version>
64
+		</dependency>
65
+
66
+		<!-- commons-beanutils -->
67
+		<dependency>
68
+			<groupId>commons-beanutils</groupId>
69
+			<artifactId>commons-beanutils</artifactId>
70
+			<version>1.9.2</version>
71
+		</dependency>
72
+		<!-- commons-lang -->
73
+		<dependency>
74
+			<groupId>commons-lang</groupId>
75
+			<artifactId>commons-lang</artifactId>
76
+			<version>2.6</version>
77
+		</dependency>
78
+
79
+		<!-- servlet -->
80
+		<dependency>
81
+			<groupId>javax.servlet</groupId>
82
+			<artifactId>servlet-api</artifactId>
83
+			<version>2.5</version>
84
+			<scope>provided</scope>
85
+		</dependency>
86
+		<dependency>
87
+			<groupId>javax.servlet.jsp</groupId>
88
+			<artifactId>jsp-api</artifactId>
89
+			<version>2.1</version>
90
+			<scope>provided</scope>
91
+		</dependency>
92
+
93
+		<!-- junit -->
94
+		<dependency>
95
+			<groupId>junit</groupId>
96
+			<artifactId>junit</artifactId>
97
+			<version>4.11</version>
98
+			<scope>test</scope>
99
+		</dependency>
100
+
101
+		<!-- c3p0 -->
102
+		<dependency>
103
+			<groupId>c3p0</groupId>
104
+			<artifactId>c3p0</artifactId>
105
+			<version>0.9.1.2</version>
106
+		</dependency>
107
+		<!-- mybatis-spring -->
108
+		<dependency>
109
+			<groupId>org.mybatis</groupId>
110
+			<artifactId>mybatis-spring</artifactId>
111
+			<version>1.2.2</version>
112
+		</dependency>
113
+		<dependency>
114
+			<groupId>org.mybatis</groupId>
115
+			<artifactId>mybatis</artifactId>
116
+			<version>3.2.8</version>
117
+		</dependency>
118
+		<!-- mysql-connector -->
119
+		<dependency>
120
+			<groupId>mysql</groupId>
121
+			<artifactId>mysql-connector-java</artifactId>
122
+			<version>5.1.29</version>
123
+		</dependency>
124
+
125
+		<!-- quartz :quartz-2.2.1/c3p0-0.9.1.1/slf4j-api-1.6.6 -->
126
+		<dependency>
127
+			<groupId>org.quartz-scheduler</groupId>
128
+			<artifactId>quartz</artifactId>
129
+			<version>2.2.1</version>
130
+		</dependency>
131
+		<!-- xxl-mq-core -->
132
+		<dependency>
133
+			<groupId>com.xxl</groupId>
134
+			<artifactId>xxl-job-core</artifactId>
135
+			<version>0.0.1-SNAPSHOT</version>
136
+		</dependency>
137
+
138
+	</dependencies>
139
+
140
+	<build>
141
+		<plugins>
142
+			<plugin>
143
+				<groupId>org.apache.maven.plugins</groupId>
144
+				<artifactId>maven-compiler-plugin</artifactId>
145
+				<version>3.1</version>
146
+				<configuration>
147
+					<source>1.6</source>
148
+					<target>1.6</target>
149
+					<encoding>UTF8</encoding>
150
+				</configuration>
151
+			</plugin>
152
+			<plugin>
153
+				<groupId>org.apache.maven.plugins</groupId>
154
+				<artifactId>maven-war-plugin</artifactId>
155
+				<version>2.2</version>
156
+				<configuration>
157
+					<archiveClasses>true</archiveClasses>
158
+				</configuration>
159
+			</plugin>
160
+		</plugins>
161
+	</build>
162
+	
163
+</project>

+ 16 - 0
xxl-job-demo/src/main/java/com/xxl/controller/IndexController.java Wyświetl plik

@@ -0,0 +1,16 @@
1
+package com.xxl.controller;
2
+
3
+import org.springframework.stereotype.Controller;
4
+import org.springframework.web.bind.annotation.RequestMapping;
5
+import org.springframework.web.bind.annotation.ResponseBody;
6
+
7
+@Controller
8
+@RequestMapping("/")
9
+public class IndexController {
10
+
11
+	@RequestMapping("")
12
+	@ResponseBody
13
+	private String index() {
14
+		return "hehe";
15
+	}
16
+}

+ 13 - 0
xxl-job-demo/src/main/java/com/xxl/service/ITriggerService.java Wyświetl plik

@@ -0,0 +1,13 @@
1
+package com.xxl.service;
2
+
3
+/**
4
+ * Trigger Service
5
+ * @author xuxueli
6
+ */
7
+public interface ITriggerService {
8
+	
9
+	/**
10
+	 * 全站静态化
11
+	 */
12
+	public void generateNetHtml();
13
+}

+ 30 - 0
xxl-job-demo/src/main/java/com/xxl/service/impl/TriggerServiceImpl.java Wyświetl plik

@@ -0,0 +1,30 @@
1
+package com.xxl.service.impl;
2
+
3
+import org.slf4j.Logger;
4
+import org.slf4j.LoggerFactory;
5
+import org.springframework.stereotype.Service;
6
+
7
+import com.xxl.service.ITriggerService;
8
+
9
+/**
10
+ * Trigger Service
11
+ * @author xuxueli
12
+ */
13
+@Service("triggerService")
14
+public class TriggerServiceImpl implements ITriggerService {
15
+	private static transient Logger logger = LoggerFactory.getLogger(TriggerServiceImpl.class);
16
+	
17
+	
18
+	/**
19
+	 * 全站静态化
20
+	 */
21
+	public void generateNetHtml() {
22
+		long start = System.currentTimeMillis();
23
+		logger.info("全站静态化... start:{}", start);
24
+		
25
+			
26
+		long end = System.currentTimeMillis();
27
+		logger.info("全站静态化... end:{}, cost:{}", end, end - start);
28
+	}
29
+	
30
+}

+ 38 - 0
xxl-job-demo/src/main/resources/applicationcontext-base.xml Wyświetl plik

@@ -0,0 +1,38 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
+	xmlns:util="http://www.springframework.org/schema/util"
5
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
6
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
+           http://www.springframework.org/schema/context
8
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd
9
+           http://www.springframework.org/schema/util 
10
+           http://www.springframework.org/schema/util/spring-util.xsd">
11
+
12
+	<context:annotation-config />
13
+	<context:component-scan base-package="com.xxl.service.impl, com.xxl.dao.impl" />
14
+
15
+	<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
16
+		<property name="templateLoaderPath" value="/WEB-INF/template/" />
17
+		<property name="freemarkerSettings">
18
+			<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
19
+				<property name="location" value="classpath:freemarker.properties" />
20
+			</bean>
21
+		</property>
22
+		<property name="freemarkerVariables">
23
+			<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
24
+				<property name="location" value="classpath:freemarker.variables.properties" />
25
+			</bean>
26
+		</property>
27
+	</bean>
28
+
29
+	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
30
+		<property name="fileEncoding" value="utf-8" />
31
+		<property name="locations">
32
+			<list>
33
+				<value>classpath*:jdbc.properties</value>
34
+			</list>
35
+		</property>
36
+	</bean>
37
+
38
+</beans>

+ 43 - 0
xxl-job-demo/src/main/resources/applicationcontext-database.xml Wyświetl plik

@@ -0,0 +1,43 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
+	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5
+	xsi:schemaLocation="
6
+		http://www.springframework.org/schema/beans 
7
+		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
8
+		http://www.springframework.org/schema/context 
9
+		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
10
+		http://www.springframework.org/schema/aop 
11
+		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
12
+		http://www.springframework.org/schema/tx 
13
+		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
14
+		
15
+	<context:annotation-config />
16
+	<context:component-scan base-package="com.xxl.service.impl, com.xxl.dao.impl" />
17
+
18
+	<!-- c3p0:Main数据源  -->
19
+	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">  
20
+	    <property name="driverClass" value="${c3p0.driverClass}" />  
21
+	    <property name="jdbcUrl" value="${c3p0.url}" />  
22
+	    <property name="user" value="${c3p0.user}" />  
23
+	    <property name="password" value="${c3p0.password}" />  
24
+	    <property name="initialPoolSize" value="3" />  
25
+	    <property name="minPoolSize" value="2" />  
26
+	    <property name="maxPoolSize" value="10" />  
27
+	    <property name="maxIdleTime" value="60" />
28
+	    <property name="acquireRetryDelay" value="1000" />
29
+	    <property name="acquireRetryAttempts" value="10" />
30
+	    <property name="preferredTestQuery" value="SELECT 1" />
31
+	</bean>
32
+	
33
+	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
34
+		<property name="dataSource" ref="dataSource" />
35
+		<property name="mapperLocations" value="classpath*:com/xxl/core/model/mapper/*.xml"/>
36
+	</bean>
37
+    
38
+    <!-- Template在Junit测试的时候,必须使用scope="prototype",原因未知 -->
39
+    <bean id="sqlSessionTemplate"  class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">  
40
+          <constructor-arg index="0" ref="sqlSessionFactory" />  
41
+    </bean> 
42
+	
43
+</beans>

+ 34 - 0
xxl-job-demo/src/main/resources/applicationcontext-trigger.xml Wyświetl plik

@@ -0,0 +1,34 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
+	xmlns:util="http://www.springframework.org/schema/util"
5
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
6
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
+           http://www.springframework.org/schema/context
8
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd
9
+           http://www.springframework.org/schema/util 
10
+           http://www.springframework.org/schema/util/spring-util.xsd">
11
+
12
+	<!-- 全站静态化:Job Detail -->
13
+	<bean id="generateNetHtmlJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
14
+		<property name="targetObject" ref="triggerService" />
15
+		<property name="targetMethod" value="generateNetHtml" />
16
+		<property name="concurrent" value="false" />
17
+	</bean>
18
+	
19
+	<!-- 全站静态化:Cron Trigger (quartz-2.x的配置) -->
20
+	<bean id="generateNetHtmlTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
21
+		<property name="jobDetail" ref="generateNetHtmlJobDetail" />
22
+		<property name="cronExpression" value="0/3 * * * * ? *" />
23
+	</bean>
24
+	
25
+	<!-- 启动触发器的配置开始 -->
26
+	<bean name="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
27
+		<property name="triggers">
28
+			<list>
29
+				<ref bean="generateNetHtmlTrigger" />
30
+			</list>
31
+		</property>
32
+	</bean>
33
+
34
+</beans>

+ 44 - 0
xxl-job-demo/src/main/resources/applicationcontext-tx.xml Wyświetl plik

@@ -0,0 +1,44 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
+	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
5
+	xsi:schemaLocation="
6
+		http://www.springframework.org/schema/beans 
7
+		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
8
+		http://www.springframework.org/schema/context 
9
+		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
10
+		http://www.springframework.org/schema/aop 
11
+		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
12
+		http://www.springframework.org/schema/tx 
13
+		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
14
+
15
+    <!-- 事务管理器(声明式事务) -->
16
+	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
17
+		<property name="dataSource" ref="dataSource" />
18
+	</bean>
19
+      
20
+	<!-- 启动事务注解(方式1:注解方式) -->
21
+	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
22
+	
23
+	<!-- 事务通知(方式2:XML事务管理) -->
24
+	<tx:advice id="txAdvice" transaction-manager="transactionManager">
25
+		<tx:attributes>
26
+			<tx:method name="detail*" propagation="SUPPORTS" />
27
+			<tx:method name="visit*" propagation="SUPPORTS" />
28
+			<tx:method name="get*" propagation="SUPPORTS" />
29
+			<tx:method name="find*" propagation="SUPPORTS" />
30
+			<tx:method name="check*" propagation="SUPPORTS" />
31
+			<tx:method name="list*" propagation="SUPPORTS" />
32
+			<tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
33
+		</tx:attributes>
34
+	</tx:advice>
35
+
36
+	<!-- AOP配置 -->
37
+	<aop:config>
38
+		<!-- 定义一个切入点 -->
39
+		<aop:pointcut id="txoperation" expression="execution(* com.xxl.service.imp.*.*(..))" />
40
+		<!-- 切入点事务通知 -->
41
+		<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
42
+	</aop:config>
43
+	
44
+</beans>

+ 10 - 0
xxl-job-demo/src/main/resources/freemarker.properties Wyświetl plik

@@ -0,0 +1,10 @@
1
+template_update_delay=0
2
+default_encoding=UTF-8
3
+output_encoding=UTF-8
4
+locale=zh_CN
5
+number_format=0.##########
6
+date_format=yyyy-MM-dd
7
+time_format=HH:mm:ss
8
+datetime_format=yyyy-MM-dd HH:mm:s
9
+classic_compatible=true
10
+template_exception_handler=ignore

+ 2 - 0
xxl-job-demo/src/main/resources/freemarker.variables.properties Wyświetl plik

@@ -0,0 +1,2 @@
1
+# 静态文件地址 
2
+static_url=https://www.baidu.com/

+ 4 - 0
xxl-job-demo/src/main/resources/jdbc.properties Wyświetl plik

@@ -0,0 +1,4 @@
1
+c3p0.driverClass=com.mysql.jdbc.Driver
2
+c3p0.url=jdbc:mysql://localhost:3306/test?Unicode=true&amp;characterEncoding=UTF-8
3
+c3p0.user=root
4
+c3p0.password=root_pwd

+ 10 - 0
xxl-job-demo/src/main/resources/log4j.properties Wyświetl plik

@@ -0,0 +1,10 @@
1
+log4j.rootLogger=info,console
2
+
3
+log4j.appender.console=org.apache.log4j.ConsoleAppender
4
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
5
+log4j.appender.console.layout.ConversionPattern=%d - xxl-job-demo - %p [%c] - <%m>%n
6
+
7
+log4j.appender.logFile=org.apache.log4j.DailyRollingFileAppender
8
+log4j.appender.logFile.File=${catalina.base}/logs/xxl-job-demo.log
9
+log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
10
+log4j.appender.logFile.layout.ConversionPattern=%d - xxl-job-demo - %p [%c] - <%m>%n

+ 50 - 0
xxl-job-demo/src/main/resources/springmvc-context.xml Wyświetl plik

@@ -0,0 +1,50 @@
1
+<?xml version="1.0" encoding="UTF-8"?> 
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+    xmlns:aop="http://www.springframework.org/schema/aop" 
4
+    xmlns:context="http://www.springframework.org/schema/context" 
5
+    xmlns:p="http://www.springframework.org/schema/p" 
6
+    xmlns:tx="http://www.springframework.org/schema/tx"
7
+    xmlns:mvc="http://www.springframework.org/schema/mvc"
8
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9
+    xsi:schemaLocation="  
10
+		http://www.springframework.org/schema/beans 
11
+		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
12
+		http://www.springframework.org/schema/context 
13
+		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
14
+		http://www.springframework.org/schema/aop 
15
+		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
16
+		http://www.springframework.org/schema/tx 
17
+		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
18
+		http://www.springframework.org/schema/mvc
19
+		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
20
+
21
+	<description>Spring-web MVC配置</description>
22
+	
23
+	<mvc:annotation-driven /> 
24
+	<context:component-scan base-package="com.xxl.controller" />
25
+	
26
+	<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />
27
+	<mvc:resources mapping="/static/**" location="/static/" />
28
+	
29
+	<bean id="viewResolver"	class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
30
+		<property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />	<!-- 解析视图模板类 -->
31
+		<property name="prefix" value="" />								<!-- 模板前后缀,指定html页面为模板 -->
32
+		<property name="suffix" value=".ftl" />
33
+		<property name="contentType" value="text/html;charset=UTF-8" />	<!-- 模板输出内容编码 (此处应与defaultEncoding保持一致) -->
34
+		<property name="exposeSpringMacroHelpers" value="true" />		<!-- 访问Request/Session宏助手 -->
35
+		<property name="exposeRequestAttributes" value="true" />		<!-- 允许访问Request属性,默认为false -->
36
+		<property name="exposeSessionAttributes" value="true" />		<!-- 允许访问Session属性,默认为false -->
37
+		<property name="requestContextAttribute" value="request" />		<!-- 将HttpServletRequest的属性存放到request这个变量中 -->
38
+		<property name="cache" value="true" />
39
+		<property name="order" value="0" />
40
+	</bean>
41
+	
42
+	<!-- <mvc:interceptors>
43
+		<mvc:interceptor>
44
+			<mvc:mapping path="/**"/>
45
+			<bean class="com.xxl.controller.interceptor.PermissionInterceptor"/>
46
+		</mvc:interceptor>
47
+	</mvc:interceptors>
48
+ 	<bean id="exceptionResolver" class="com.xxl.controller.resolver.WebExceptionResolver" /> -->
49
+	
50
+</beans>

+ 55 - 0
xxl-job-demo/src/main/webapp/WEB-INF/web.xml Wyświetl plik

@@ -0,0 +1,55 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
+	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5
+	id="WebApp_ID" version="2.5">
6
+	<display-name>xxl-job-demo</display-name>
7
+
8
+	<context-param>
9
+		<param-name>contextConfigLocation</param-name>
10
+		<param-value>classpath*:applicationcontext-*.xml</param-value>
11
+	</context-param>
12
+
13
+	<listener>
14
+		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
15
+	</listener>
16
+	<listener>
17
+		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
18
+	</listener>
19
+
20
+	<filter>
21
+		<filter-name>encodingFilter</filter-name>
22
+		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
23
+		<init-param>
24
+			<param-name>encoding</param-name>
25
+			<param-value>UTF-8</param-value>
26
+		</init-param>
27
+		<init-param>
28
+			<param-name>forceEncoding</param-name>
29
+			<param-value>true</param-value>
30
+		</init-param>
31
+	</filter>
32
+	<filter-mapping>
33
+		<filter-name>encodingFilter</filter-name>
34
+		<url-pattern>/*</url-pattern>
35
+	</filter-mapping>
36
+
37
+	<servlet>
38
+		<servlet-name>springmvc</servlet-name>
39
+		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
40
+		<init-param>
41
+			<param-name>contextConfigLocation</param-name>
42
+			<param-value>classpath*:springmvc-context.xml</param-value>
43
+		</init-param>
44
+		<load-on-startup>1</load-on-startup>
45
+	</servlet>
46
+	<servlet-mapping>
47
+		<servlet-name>springmvc</servlet-name>
48
+		<url-pattern>/</url-pattern>
49
+	</servlet-mapping>
50
+
51
+	<welcome-file-list>
52
+		<welcome-file>index.html</welcome-file>
53
+	</welcome-file-list>
54
+
55
+</web-app>