1. 项目结构图
2. TestTimer.Java 代码
package test; import org.springframework.stereotype.Repository; @Repository(value = "dispatchService") public class TestTimer { public static int timer = -1; protected void executeInternal() { timer++; System.out.println(timer); } }
3. web.xml配置
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring.xml,/WEB-INF/TimerConfig.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <servlet> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
4. TimerConfig.xml配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="activateCardJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject"> <!-- targetObject是Spring定时器的特殊属性 --> <ref bean="dispatchService" /> <!-- 这个就是具体实现类,如果是注解,则必须为component指定value --> </property> <property name="targetMethod"> <!-- targetMethod是Spring定时器的特殊属性 --> <value>executeInternal</value><!-- 就是java类中的任务方法 --> </property> </bean> <bean id="sayRunTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail"><!-- jobDetail是Spring定时器的特殊属性 --> <ref bean="activateCardJobDetail" /> </property> <property name="cronExpression"> <value>0 */1 * * * ?</value><!-- cronExpression是Spring定时器的特殊属性 --> </property> <property name="startDelay"> <value>0</value> <!-- 容器启动后 延时 0毫秒 后 定时器开始启动 --> </property> </bean> <bean autowire="no" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <!-- triggers是Spring定时器的特殊属性 --> <list> <ref bean="sayRunTrigger" /> </list> </property> <property name="autoStartup" value="true" /> <!-- 自动启动定时任务 --> </bean> </beans>
5. spring.xml配置
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:cache="http://www.springframework.org/schema/cache" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <!-- 启动包扫描功能,以便注册带有@Controller、@Service、@repository、@Component等注解的类成为spring的bean --> <context:component-scan base-package="test" /> </beans>
6. spring-servlet.xml配置
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <!-- 启动注解驱动的Spring MVC功能,注册请求url和注解POJO类方法的映射 --> <mvc:annotation-driven /> <!-- 对模型视图名称的解析,在请求时模型视图名称添加前后缀 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"> </property> <property name="prefix" value="/WEB-INF/view/"></property> <property name="suffix" value=".jsp"></property> </bean> </beans>
7. jar 包结构
8.执行结果
附件上传工程的时候 老是卡着出错......
相关推荐
spring4.0.6+quartz 2.2.3 集群示例
本项目来源与网络,本人对项目...直接通过mvn 倒入项目,在Spring-quartz-demo\src\main\webapp\sql 有sql 建立数据库,表 启动tomcat 直接访问http://localhost:8080/Spring-quartz-demo/task/taskList.htm 就可以使用
springMVC4.0.6+spring4.0.6+hibernate4.3.6框架,基本的包结构,dao基础类的封装,rowmapper,分页等工具类的封装。
使用quartz-2.2.1实现任务,结合spring4.0.6稳定版本 ,完整完整完整完整demo
Maven多模块 + Spring4.0.6 + SpringMVC4.0.6 + Mybatis 3.2.7 + log4j 2.1
spring4.0.6 +mybatis 3.2.7整合包 Druid1.0.6+jackson2.4+junit4.11
spring-framework-4.0.6.RELEASE-dist 所需全部jar包
采用hibernate 4.3.6,spring 4.0.6 ,实现jpa配置,简单易懂明了。压缩文件中包含jpa依赖的hibernate包,如果下载者希望运行,需要自己写实体类。压缩包中含有精简的配置。
Spring4.0.6+Struts2.3.16.3整合架包下载,ss整合jar架包下载,最新spring和struts整合架包下载
本博客源码采用hibernate4.3.6+spring4.0.6+struts2.3.16整合开发,集成memcached。加入本地缓存。html5前端页面,清一色ajax加载,后端采用easyUi。后台功能有待完善。By:WebSos
这是目前最新的Spring库文件,以及Hibernate库文件,并提供DBCP2为数据源,加以Pool2。
需要整合SSH框架最新jar包的朋友可以下载
spring-tx-4.0.6.RELEASE.jar spring-tx-4.0.6.RELEASE.jar
最新ssh jar包(struts2.3.16.3+hibernate4.3.6+spring-4.0.6 )整合。 官网下载确实很麻烦,尤其是spring。我这里就帮大伙下好了,并整合好了,不过需要jdk1.8。
包含spring 4.0.6全部jar包 4.0.6稳定版本 spring-aop-4.0.6.RELEASE.jar等
Unas,系统简洁好用,对系统配置要求低,系统内置docker和2种虚拟机平台,下载工具。官网下载速度慢,放这里大家下载用。
RavenDB-4.0.6-patch-40047-windows-x64 RavenDB-4.0.6-patch-40047-windows-x64
下载完成使用以下命令完成安装:pip install numpy-1.18.1-cp37-cp37m-win_amd64.whl Pillow-7.0.0-cp37-cp37m-win_amd64.whl six-1.14.0-py2.py3-none-any.whl wxPython-4.0.6-cp37-cp37m-win_amd64.whl
springmvc4.0.6+activiti 5.16.4 + beetl 2.2.3整合
压缩包包括spring-framework-4.0.6.RELEASE 全部jar包。