原文:http://www.cnblogs.com/LiuChunfu/p/5605473.html

------------------------------------------------------------------------------

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

二、引入properties文件。

方法1:

    <!--引入数据库配置信息 --><context:property-placeholder location="classpath*:properties/db.properties" />

方法2:

情况1配置一个:

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="location" value="classpath*:db/jdbc.properties" /></bean>

情况2配置多个:

    <bean id="propertyConfigure" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><list><value>classpath:/opt/demo/config/demo-db.properties</value> <value>classpath:/opt/demo/config/demo-db2.properties</value> </list></property></bean>

这些properties中就是key-value的键值对,使用的时候可以使用${xxx} 获取。

Spring中引入其他配置文件相关推荐

  1. 如何在spring中读取properties配置文件里面的信息

    如何在spring中读取properties配置文件里面的信息 <!-- 正文开始 --> 一般来说.我们会将一些配置的信息放在.properties文件中. 然后使用${}将配置文件中的 ...

  2. spring加载jar包中多个配置文件(转)

    转自:http://evan0625.iteye.com/blog/1598366 在使用spring加载jar包中的配置文件时,不支持通配符,需要一个一个引入,如下所示: Java代码 <co ...

  3. spring学习笔记之配置文件applicationContext.xml

    1:spring中,用配置文件时 <bean>的<scope>属性是singleton时在创建容器时创建对象,创建一个容器在,对象在: <bean>的<sco ...

  4. Spring依赖注入的方式、类型、Bean的作用域、自动注入、在Spring配置文件中引入属性文件...

    1.Spring依赖注入的方式 通过set方法完成依赖注入 通过构造方法完成依赖注入 2.依赖注入的类型 基本数据类型和字符串 使用value属性 如果是指向另一个对象的引入 使用ref属性 User ...

  5. Spring配置文件中引入properties文件

    jdbc.properties文件中有信息如下: username=root url=jdbc:mysql://localhost:3306/qw?characterEncoding=utf8 dri ...

  6. spring中的注解和xml配置文件中配置对应总结

    spring中的注解和xml配置文件中配置对应 需要导入的jar spring-context spring-context-support spring-test commons-logging b ...

  7. [5] Spring中的AOP操作(使用xml 配置文件的方式)

    AOP (Aspect Oriented Programing) 面向切面编程 AOP 采取横向抽取机制,取代了传统的纵向继承体系重复性代码(性能监视.事务管理.安全检查.缓存) Spring AOP ...

  8. Spring中加载xml配置文件的六种方式

    Spring中加载xml配置文件的六种方式 博客分类: Spring&EJB XMLSpringWebBeanBlog  因为目前正在从事一个项目,项目中一个需求就是所有的功能都是插件的形式装 ...

  9. 解决Spring boot中读取属性配置文件出现中文乱码的问题

    解决Spring boot中读取属性配置文件出现中文乱码的问题 参考文章: (1)解决Spring boot中读取属性配置文件出现中文乱码的问题 (2)https://www.cnblogs.com/ ...

最新文章

  1. EditText 长按弹出的上下文菜单
  2. iOS和OS X中的bundle
  3. spring boot 传递 List参数
  4. windows下安装RabbitMQ消息服务器 + 读写队列
  5. java中的方法在哪里_Java中的本机方法是什么,应在哪里使用?
  6. kafka0.9 java commit_Kafka 0.9 新消费者API
  7. java server.xml_tomcat配置文件server.xml详解
  8. Kubernetes学习之路(26)之kubeasz+ansible部署集群
  9. python os模块进程管理
  10. Oracle报错01756,oracle导入数据报错处理
  11. 握奇ukey没证书_握奇USB KEY
  12. python数据挖掘入门与实践-第一章-用最简单OneR算法对Iris植物分类
  13. 本科三本的计算机博士,读书中的我 从三本本科到985博士
  14. jsp:关于ArrayList
  15. 批量修改图片名称的快捷方法
  16. a DNS-1123 label must consist of lower case alphanumeric characters or ‘-‘, and must start and end w
  17. 最详细的A/B test 原理
  18. 信号signal ---带数据的信号的发送及安装
  19. mysql的循环语句(循环插入数据)
  20. 教你修改网卡物理地址(MAC)

热门文章

  1. imx226_相机选型器
  2. Linux常用命令与基本操作、填空题、简答题
  3. SQL2012(32位)下载及安装(32位、64位都一样,不影响)
  4. lintcode Permutation Index
  5. java接口的应用举例
  6. php times33,PHP Hash算法:Times33算法代码实例
  7. Xctf练习sql注入--supersqli
  8. 软件开发模型_QT开发(二十三)——软件开发流程
  9. python控制台清屏_Python Shell 怎样清屏?
  10. python读取多个文件csv_Python:读取多个文本文件并写入相应的csv文件