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 ...
随机推荐
- 【win10】更改资源管理器显示:快速访问和此电脑
通常,我习惯通过按 win+E来打开资源管理器,然后显示各个分区并进行操作.在win10打开资源管理器默认显示的是快速访问,并不是显示的分区.下面是修改步骤. 1.按Win+E打开资源管理器,点击[查 ...
- Shell----简单整理
------------------------------------------------------------------Shell脚本--------------------------- ...
- (domain)域名协议
https://jingyan.baidu.com/article/2c8c281df0afd00008252aa7.html
- tensorflow的assgin方法
官网API是这么说的 This operation outputs a Tensor that holds the new value of 'ref' after the value has bee ...
- Linear transformations. 线性变换与矩阵的关系
0.2.2 Linear transformations. Let U be an n-dimensional vector space and let V be an m-dimensional v ...
- [knowledge][perl][pcre][sed] sed / PCRE 语法/正则表达式
一直用sed一直没有正经的学过语法,一直一知半解的用着. 因为,它用来perl的语法,要想搞懂,首先要搞懂perl,系统的入个门... 之前,man sed,man了好多次,总是没找到关键内容,今天在 ...
- odoo权限管理
Odoo的权限的核心是权限组(res_groups).对每个权限组,可以设置权限组的菜单表示,对象表示,记录规则表示,字段表示. 1.菜单/对象级别 设置哪些人可以访问哪些菜单/对象,对象的访问权限包 ...
- day2_webservice接口怎么测-SoapUI
可以用SoapUI工具测试 步骤: 1.新建soap project Ok后左侧出现接口内容 2.输入参数执行 3.根据需求文档的参数返回值做对比
- ASMCMD报错解决:sh: /u01/app/11.2.4/grid/bin/clsecho: No such file or directory
sh: /u01/app/11.2.4/grid/bin/clsecho: No such file or directory 在登录asmcmd时报此错误,尝试解决,刷新oracle_sid也不行 ...
- LeetCode 476 Number Complement 解题报告
题目要求 Given a positive integer, output its complement number. The complement strategy is to flip the ...