0

我正在使用 Eclipse Helios。我有一个动态 Web 项目。

我想使用 Spring 3.1.0 加载一个属性文件,为此我使用以下配置

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>classpath:resources/dc-config.properties</value>
        </property>
    </bean>

此文件夹按名称资源存在于 WEB-INF/classes 目录中

但是当我尝试启动我的 Tomcat 6 服务器时,我收到以下错误

Caused by: java.util.MissingResourceException: Can't find bundle for base name dc-config, locale en_US

是不是我的资源文件夹在类路径中,因为它在类文件夹中,而类文件夹又在类路径中?

如果我在这里遗漏了什么,请告诉我

4

2 回答 2

0

可能是错误的 bean 类?试试这个:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
 <property name="basenames">
   <list>
     <value>classpath:resources/dc-config</value>
    </list>
  </property>
</bean>
于 2012-04-27T11:53:16.920 回答
0

也许问题是一个小错字。尝试任一

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location"> <!-- not locations -->
            <value>classpath:resources/dc-config.properties</value>
        </property>
    </bean>

或者

     <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
        <list>
            <value>classpath:resources/dc-config.properties</value>
        </list>
        </property>
    </bean>
于 2012-04-27T12:09:23.530 回答