发表于: java/j2ee | 作者: | 日期: 2011/6/01 07:06

在定义spring配置文件的时候将不同模块的配置放在不同的配置文件中,这样可以使程序的结构更加清晰。总结了一下spring中使用多配置文件的方法。

方法一:
在web.xml文件中将所有配置文件引入:


contextConfigLocation classpath*:/applicationContext.xml
classpath*:/applicationContext-memcached.xml

org.springframework.web.context.ContextLoaderListener

说明:

(1)如果只有一个配置文件,并且文件名为applicationContext.xml ,则只需在web.xml文件中增加如下代码即可:

org.springframework.web.context.ContextLoaderListener

(2)contextConfigLocation用来指定多个配置文件,这些配置文件可以使用逗号、分号、空格作为分隔符,或者一个配置文件一行也可以,Spring 的ContextLoaderListener 负责将该字符串分解成多个配置文件。

方法二:
使用import标签:



: https://blog.darkmi.com/2011/06/01/1837.html

本文相关评论 - 1条评论都没有呢
Post a comment now » 本文目前不可评论

No comments yet.

Sorry, the comment form is closed at this time.