引入其他模块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>

最新文章

  1. POJ1273Drainage Ditches[最大流]
  2. Appcelerator Titanium Studio: JNI_CreateJavaVM missing error
  3. 基于MVC4+EasyUI的Web开发框架形成之旅--框架总体界面介绍
  4. protoc 和 protoc-gen-go 产生的 proto 文件代码对比
  5. net IL的一些探索
  6. CLR via C# 混合线程同步构造
  7. javascript算法汇总(持续更新中)
  8. Response.ContentType 详细列表 &lt;转&gt;
  9. 【转载】django在eclipse环境下建web网站
  10. C——联合体(共同体)总结
  11. libevent总结学习
  12. thinkjs之页面跳转
  13. axios 中文文档(转载)
  14. 体验Hadoop3.0生态圈-CDH6.1时代的来临
  15. java实现把对象数组通过excel方式导出的功能
  16. QMenu 设置菜单图标 &amp; 生成菜单树
  17. The MySQL Server
  18. spring 的 切片Aspect 最常用记录方法执行时间
  19. Django--URL(路由层)
  20. JavaScript -- URL编码

热门文章

  1. simhash与Google的网页去重
  2. 1. Ubuntu下MongoDB的安装和使用
  3. 发送短信功能(C#)
  4. Winform生成安装程序时配置自启动
  5. ASP.NET MVC使用SignalR统计在线用户人数
  6. linux03
  7. Flask系列07--Flask中的CBV, 蓝图的CBV
  8. 混合表单文件上传到数据库(基于TOMCAT)
  9. MariaDB 插入&amp;更新&amp;删除数据(8)
  10. C#6.0语言规范(十) 类