引入其他模块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=" " />标签使用总结的更多相关文章

  1. spring配置文件引入properties文件:<context:property-placeholder>标签使用总结

    一.问题描述: 1.有些参数在某些阶段中是常量,比如: (1)在开发阶段我们连接数据库时的连接url.username.password.driverClass等 (2)分布式应用中client端访问 ...

  2. spring 框架的xml文件如何读取properties文件数据

    spring 框架的xml文件如何读取properties文件数据 第一步:在spring配置文件中 注意:value可以多配置几个properties文件 <bean id="pro ...

  3. Spring的applicationContext.xml文件

    以下是详解Spring的applicationContext.xml文件代码:<!-- 头文件,主要注意一下编码 --><?xml version="1.0" e ...

  4. Spring配置文件beans.xml头部配置解释

    Spring配置文件beans.xml头部配置解释 - EasonJim - 博客园https://www.cnblogs.com/EasonJim/p/6880329.html

  5. Spring MVC 配置文件dispatcher-servlet.xml 文件详解

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  6. Spring MVC 配置文件dispatcher-servlet.xml 文件详解(转自 学无止境-yj)

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  7. spring 配置文件 引入外部的property文件的两种方法

    spring  的配置文件 引入外部的property文件的两种方法 <!-- 引入jdbc配置文件    方法一 --> <bean id="propertyConfig ...

  8. springboot-16-springboot中引入xml文件

    参考原文: http://412887952-qq-com.iteye.com/blog/2293846 使用的是在spring中注入一个bean的方式来测试是否成功, 感觉略不实用, 只碰到过一次d ...

  9. Spring中的资源文件框架——Resource

    摘要 Spring4 以后,官方推荐我们使用Java Config来代替applicationContext.xml,声明将Bean交给容器管理. 在Spring Boot中,Java Config的 ...

随机推荐

  1. Linux 修改默认的 yum 源

    官方的yum源在国内访问效果不佳. 需要改为国内比较好的阿里的 yum源,因为每次装的时候都得百度,所以这里记录一下. 修改方式: 1)cd /etc/yum.repos.d/ 这个目录下普通用户可能 ...

  2. SQL语句 删除表user 中字段name 内容重复的记录,

    public class T01 { public static void main(String[] args) { int j=4; j=j+=j-=j*=j; System.out.printl ...

  3. shell 命令 ls -a

    接手其他人的shell脚本时,遇到了一个"."开头的文件目录, ll 始终找不到. 咨询了一下,才知道,"."开头的是隐藏文件. 这时候用 ll -a 或 ls ...

  4. 笑话库存加网址http://www.jokeji.cn/list18_11.htm

    19.富二代王晓伟成绩很差,老爸想给他找个家教老爸:“儿子,想找什么样的家教啊?”儿子:“要漂亮的,女的,衣服不能太保守,花样要多!”老爸:“儿子,你TM指的是岛国的苍老师吗?”@呦呦ta爹 20.哥 ...

  5. Modeless对话框如何响应快捷键

    MFC,Modeless对话框不会响应快捷键.解决的方案很多,其中之一是在PreTranslateMessage中地键盘消息进行拦截处理.

  6. SignalR简介

    什么是SignalR? ASP.NET SignalR是ASP.NET开发人员的库,它简化了向应用程序添加实时Web功能的过程.实时Web功能是指服务器代码在连接的客户端可用时立即将内容推送到连接的客 ...

  7. ASP.NET MVC WebAPI实现文件批量上传

    工作中学习,学习中记录~~~~~~ 最下面附上demo 任务需求:需要做一个apI接口让C#的程序调用实现批量文件的上传. 难度: 没有做过通过API上传文件的...之前做过网站前后台上传. 首先当然 ...

  8. Android---------------解决bug的关键点

    一.抛出异常,打出异常的的堆信息 System.err.print("ceshi");      e.printStackTrace();     Log.i("cesh ...

  9. 在centos使用redis几个坑

    问题来源 最近公司的平台需要做一些分布式的规划,其中会话我们打算用redis来存储,因为之前也有了解过redis,但都是在windows上使用,为了发挥redis的优势,这次我们打算直接在Linux上 ...

  10. spring-boot集成thymeleaf。

    thymeleaf是前台页面展示,原来一直是jsp,jsp中包含很多服务器端的逻辑,逐渐淘汰.同样功能的还有freemarker.孰好孰坏不予评价,只做简单实现. 1.基本思路 (1)pom.xml中 ...