在tomcat上使用spring通配符

时间:2014-12-05 14:17:24

标签: java spring tomcat wildcard

我有一个war,其中包含许多JAR,其中大多数都有properties个文件。我的目标是在spring上下文中加载所有这些properties文件,但显然它不会以某种方式在tomcat上运行。

<bean class="test.NoMessagesPropertiesFactoryBean">
    <property name="locations">
        <array>
            <value>classpath*:/**/*.properties</value>
        </array>
    </property>
</bean>

假设我的模块testWebapp为<packaging>war</packaging>,因此此模块中的每个属性文件都将以<filename>.war/WEB-INF/classes/...结尾 我还有testProperty.jar,它放在/WEB-INF/lib/中,这个jar包含一些属性文件。使用上面的配置,只加载来自testWebapp的属性文件。如何配置它以从放置在lib目录中的jar中获取属性文件(当然不需要明确地将每个文件名放在spring上下文中)?

电流:

INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@203feeda: defining beans [test.NoMessagesPropertiesFactoryBean#0]; root of factory hierarchy Dec 05, 2014 3:01:54 PM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties INFO: Loading properties file from file [D:\dev\apache-tomcat-7.0.57\webapps\test\WEB-INF\classes\test\testWebapp.properties]

预期:

INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2ac302a0: defining beans [test.NoMessagesPropertiesFactoryBean#0]; root of factory hierarchy Dec 05, 2014 3:15:28 PM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties INFO: Loading properties file from file [D:\dev\apache-tomcat-7.0.57\webapps\test\WEB-INF\classes\test\testWebapp.properties] Dec 05, 2014 3:15:28 PM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties INFO: Loading properties file from class path resource [test2/test2.properties] Context started

0 个答案:

没有答案