Spring MVC定时服务
spring-mvc-config.xml
<context:component-scan base-package="com.bf" ></context:component-scan> <task:annotation-driven /> <mvc:annotation-driven />
spring-core-config.xml
<context:component-scan base-package="com.bf" >
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/> <!--需要保留此声明,以便单元测试可用-->
</context:component-scan>
web.xml
<!-- For web context -->
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <!-- For root context -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-core-config.xml</param-value>
</context-param>
@Component
public class AutoService {
private static Logger logger = Logger.getLogger(AutoService.class);
@Autowired private MemberWechatService memberWechatService; /* cron表达式:
*(秒0-59)
*(分钟0-59)
*(小时0-23)
*(日期1-31)
*(月份1-12或是JAN-DEC)
*(星期1-7或是SUN-SAT) */ @Scheduled(cron = "0 32 * * * *") //每周日下午6:00
public void notifyTutor() {
Server.xml
<Host autoDeploy="true" name="localhost" unpackWARs="true">
这种配置可以定义执行。
但是以下配置方式,对事务是有效的,感觉事务与定时服务有冲突,没找到解决办法
spring-mvc-config.xml
<context:component-scan base-package="com.bf" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
Spring MVC定时服务的更多相关文章
- Spring MVC Rest服务 返回json报406错误的解决办法
@ResponseBody & @RequestBody @RequestBody 将 HTTP 请求正文插入方法中,使用适合的HttpMessageConverter将请求体写入某个对象. ...
- UEditor1.4.3.3整合Spring MVC和七牛
[前言] 项目中涉及将UEditor上传服务器整合进已有的基于Spring MVC的服务中,并且将上传到本地改为上传到七牛,看似简单的一个需求,实际做起来还是遇到了一些困难.在这里分享一下经验-- 七 ...
- Spring MVC 设计概述
MVC设计的根本原因在于解耦各个模块 Spring MVC的架构 对于持久层而言,随着软件发展,迁移数据库的可能性很小,所以在大部分情况下都用不到Hibernate的HQL来满足移植数据库的要求. ...
- 应用Spring MVC发布restful服务是怎样的一种体验
摘要:“约定优于配置”这是一个相当棒的经验,SOAP服务性能差.基于配置.紧耦合,restful服务性能好.基于约定.松耦合,现在我就把使用Spring MVC发布restful服务的 ...
- spring mvc + freemarker优雅的实现邮件定时发送
1. spring mvc工程中引入相关freemarker\mail的包 如:pom.xml中加入类似 <dependency> <groupId>javax.mail< ...
- JSR-303 Bean Validation 介绍及 Spring MVC 服务端参数验证最佳实践
任何时候,当要处理一个应用程序的业务逻辑,数据校验是你必须要考虑和面对的事情. 应用程序必须通过某种手段来确保输入参数在上下文来说是正确的. 分层的应用很多时候同样的数据验证逻辑会出现在不同的层,这样 ...
- JSR-303 Bean Validation 介绍及 Spring MVC 服务端验证最佳实践
任何时候,当要处理一个应用程序的业务逻辑,数据校验是你必须要考虑和面对的事情. 应用程序必须通过某种手段来确保输入参数在上下文来说是正确的. 分层的应用在很多时候,同样的数据验证逻辑会出现在不同的层, ...
- 译:7.使用Spring MVC服务Web内容
本指南向您介绍了使用Spring创建“hello world”网站的过程.阅读原文:Serving Web Content with Spring MVC 1. 你将会构建什么? 您将构建一个具有静态 ...
- 关于使用spring mvc或者resteasy构建restful服务的差别与比较
resteasy 是 jboss的一个开源java api for restful service(JSR 311,sun 2008年发布,最新GA版本是2.0, JAX-RS 2.0 (JSR-33 ...
随机推荐
- iOS - 高德地图将地图的多点连线
@property (nonatomic, strong) MAPolyline *commonPoly; #pragma mark -- 将地图的点连线 - (void)createBrokenLi ...
- TensorFlow—softmax_cross_entropy_with_logits函数详解
softmax_cross_entropy_with_logits函数原型: tf.nn.softmax_cross_entropy_with_logits(labels=y, logits=pred ...
- ssm文件配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- VIVE pro和hololens购买调研
VIVE pro专业版是一款虚拟现实头盔 VIVE Pro专业版头显 ¥6,488 仅含头显,不含定位器及操控手柄送VIVEPORT会员服务2个月 订购VIVE Pro专业版头显,加 ¥2,400可得 ...
- Navicat工具、pymysql模块 sql注入
cls超 Navicat工具.pymysql模块 阅读目录 一 IDE工具介绍 二 pymysql模块 一 IDE工具介绍(Navicat) 生产环境还是推荐使用mysql命令行,但为了方便我们测试, ...
- 用Python下载美国国家气候数据中心(NCDC)的气候数据
美国国家气候数据中心的官网地址是https://www.ncdc.noaa.gov/ 气候数据的下载地址是: 长格式:ftp://ftp.ncdc.noaa.gov/pub/data/noaa/,这种 ...
- [No000016A]CSS常用三种选择器
1.HTML Tag p{color:red;} 2.id #myid{color:red;} 3.class .myclass{color:red;} CSS常用文本样式属性 color font- ...
- hdu6435 Problem J. CSGO标程讲解以及改正标程的一个错误(本来第一个样例过不了2333) 以及 poj2926 五维曼哈顿距离模板
比赛的时候抄poj2926的模板,但改不来啊orz #include <iostream> #include <cstdio> #include <cstring> ...
- sed中支持变量的处理方法
1.eval sed ’s/$a/$b/’ filename2.sed "s/$a/$b/" filename3.sed ’s/’$a’/’$b’/’ filename 4.sed ...
- 2014年蓝桥杯省赛A组c++第3题(数组构造+暴力求解)
/* 标题:神奇算式 由4个不同的数字,组成的一个乘法算式,它们的乘积仍然由这4个数字组成. 比如: 210 x 6 = 1260 8 x 473 = 3784 27 x 81 = 2187 都符合要 ...