Spring配置文件引入xml文件: <import resource=" " />标签使用总结
引入其他模块XML
在Spring的配置文件,有时候为了分模块的更加清晰的进行相关实体类的配置。
比如现在有一个job-timer.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="testQuartz" class="com.mc.bsframe.job.TestJob"></bean> <!-- 将需要执行的定时任务注入JOB中。 -->
<bean id="testJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="testQuartz"></property>
<!-- 任务类中需要执行的方法 -->
<property name="targetMethod" value="doSomething"></property>
<!-- 上一次未执行完成的,要等待有再执行。 -->
<property name="concurrent" value="false"></property>
</bean> <!-- 基本的定时器,会绑定具体的任务。 -->
<bean id="testTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail" ref="testJob"></property>
<property name="startDelay" value="3000"></property>
<property name="repeatInterval" value="200000"></property>
</bean> <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="testTrigger"></ref>
</list>
</property>
</bean>
</beans>
在Spring的整体的配置文件中使用 <import resource="classpath*:/spring/job-timer.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:scpan="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 会自动扫描com.mc.bsframe下的所有包,包括子包下除了@Controller的类。 -->
<scpan:component-scan base-package="com.mc.bsframe">
<scpan:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<scpan:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" />
</scpan:component-scan> <!-- Spring中引入其他配置文件 -->
<import resource="classpath*:/spring/job-timer.xml" /> </beans>
Spring配置文件引入xml文件: <import resource=" " />标签使用总结的更多相关文章
- spring配置文件引入properties文件:<context:property-placeholder>标签使用总结
一.问题描述: 1.有些参数在某些阶段中是常量,比如: (1)在开发阶段我们连接数据库时的连接url.username.password.driverClass等 (2)分布式应用中client端访问 ...
- spring 框架的xml文件如何读取properties文件数据
spring 框架的xml文件如何读取properties文件数据 第一步:在spring配置文件中 注意:value可以多配置几个properties文件 <bean id="pro ...
- Spring的applicationContext.xml文件
以下是详解Spring的applicationContext.xml文件代码:<!-- 头文件,主要注意一下编码 --><?xml version="1.0" e ...
- Spring配置文件beans.xml头部配置解释
Spring配置文件beans.xml头部配置解释 - EasonJim - 博客园https://www.cnblogs.com/EasonJim/p/6880329.html
- Spring MVC 配置文件dispatcher-servlet.xml 文件详解
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- Spring MVC 配置文件dispatcher-servlet.xml 文件详解(转自 学无止境-yj)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- spring 配置文件 引入外部的property文件的两种方法
spring 的配置文件 引入外部的property文件的两种方法 <!-- 引入jdbc配置文件 方法一 --> <bean id="propertyConfig ...
- springboot-16-springboot中引入xml文件
参考原文: http://412887952-qq-com.iteye.com/blog/2293846 使用的是在spring中注入一个bean的方式来测试是否成功, 感觉略不实用, 只碰到过一次d ...
- Spring中的资源文件框架——Resource
摘要 Spring4 以后,官方推荐我们使用Java Config来代替applicationContext.xml,声明将Bean交给容器管理. 在Spring Boot中,Java Config的 ...
随机推荐
- 分类算法之朴素贝叶斯分类(Naive Bayesian classification)
1.1.摘要 贝叶斯分类是一类分类算法的总称,这类算法均以贝叶斯定理为基础,故统称为贝叶斯分类.本文作为分类算法的第一篇,将首先介绍分类问题,对分类问题进行一个正式的定义.然后,介绍贝叶斯分类算法的基 ...
- HDU2955 01背包
http://acm.hdu.edu.cn/showproblem.php?pid=2955 题目大意:给你一个劫匪抢银行的最高安全概率,给你银行得到钱数,和劫匪在这个银行可以逃跑的概率,问你最多能抢 ...
- SRM471
250pt: 题意:定义一种函数f(x),表示x不断/2直到出现非素数的操作次数.现在给定N,D.求X<= N, 并且f(x) >= D的最大的数 思路:直接先弄一个1000w以内的质数表 ...
- Python自动化开发 - 流程控制
一.拾遗主题 1.变量 理解变量在计算机内存中的表示 >>> a = "ABC" Python解释器干了两件事情: 在内存中创建了一个'ABC'的字符串: 在内存 ...
- windows 2008远程桌面企业协议号
windows 2008远程桌面企业协议号 6565792 (2015-01-07 14:47:31) 转载▼ 标签: it 桌面 终端服务器 客户端 服务器 分类: 操作系统/办公软件 微软的终端服 ...
- hdu 1012 素数判定
这道题~以前判定prime是一个个去试着整除再去存储,上次弄过欧拉函数那题目之后就知道了,这样会更快捷: prime[] = prime[] = ; ; i <maxn; i++) { if(! ...
- Word 如何实现表格快速一分为二
将光标定位在分断处,按快捷键“Ctrl+Shift+Enter“
- c#中的几种Dialog
1.OpenFileDialog private void FileOpen_Click(object sender, EventArgs e) { OpenFileDialog openFile = ...
- C# 中使用Linq和Lambda表达式对List<T>进行排序
C#中List<T>排序的两种方法 List<Student> stu = (List<Student>)Session["StudentList&quo ...
- [WPF]为旧版本的应用添加触控支持
之前做WPF开发时曾经遇到这样一个需求:为一个基于 .NET Framework 3.5开发的老旧WPF程序添加触控支持,以便于大屏触控展示. 接手之后发现这是一个大坑. 项目最初的时候完全没考虑过软 ...