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的 ...
随机推荐
- [leet code 165]Compare Version Numbers
1 题目 Compare two version numbers version1 and version2.If version1 > version2 return 1, if versio ...
- Constructor in depth
There are two types of constructor:Instance Constructor and Type Constructor(or so-called Static Con ...
- URL SCAN简介
URL Scan简介 文/玄魂 目录 URL Scan简介 前言 1.1 安装 1.2 配置 修改 URLScan.ini 文件 配置 URLScan 用于依赖于 IIS 的应用程序 前言 Ur ...
- 查询字段描述sql-postgresql
查询字段描述sql SELECT 'comment on column ' || n.nspname ||'.'|| c.relname || '.' || a.attname ||' is '''| ...
- Winform相关
(1)C# WinForm程序退出的方法 1.this.Close(); 只是关闭当前窗口,若不是主窗体的话,是无法退出程序的,另外若有托管线程(非主线程),也无法干净地退出: 2.Applica ...
- ASP.Net MVC OA项目笔记<二>
1.1.0 创建数据层 1.1.1 CZBK.ItcastOA.IDAL 引用 CZBK.ItcastOA.Model 1.2.1 给IDAL添加一个接口IUserInfoDal 里面写增删改查分页的 ...
- 【算法python实现】 -- 最大子序和
原题:https://leetcode-cn.com/problems/maximum-subarray/ 问题描述: 输入:[-2, 1, -3, 4, -1, 2, 1, -5, 4], 输出:6 ...
- (干货) Android实现ImageVIew多点触控及双击缩放
支持多点触控,放大自由移动,双击可以放大缩小.直接上代码: package com.cbt.view; import android.content.Context; import android.g ...
- Spring boot中使用log4j
我们知道,Spring Boot中默认日志工具为logback,但是对于习惯了log4j的开发者,Spring Boot依然可以很好的支持,只是需要做一些小小的配置功能.Spring Boot使用lo ...
- socket http tcp udp ip 协议
Socket可以支持不同的传输层协议(TCP或UDP),当使用TCP协议进行连接时,该Socket连接就是一个TCP连接. socket是在应用层和传输层之间的一个抽象层,它把TCP/IP层复杂的操作 ...