2012-04-27 120 views
0

我正在使用Eclipse Helios。我有一个动态Web项目。Java 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 

Isin't我的资源文件夹中的类路径,因为它是在类文件夹而这又是在T他的类路径?

请让我知道如果我在这里丢失的东西

+0

你试过命名属性文件dc-config_en_US.properties? – flash 2012-04-27 11:47:12

+0

是的,我已经尝试过了,那也行不通:-( – 2012-04-27 11:51:15

回答

0

错误的bean类也许? 试试这个:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
<property name="basenames"> 
    <list> 
    <value>classpath:resources/dc-config</value> 
    </list> 
    </property> 
</bean> 
+0

nope这也不起作用!! – 2012-04-27 11:57:18

+0

是春天当你看日志实际上创建的豆吗? – Farid 2012-04-27 12:11:03

+0

嗨我得到它的工作。我的组件没有被扫描,导致我的autowire无法运行 – 2012-05-03 05:41:30

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>