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 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 に答える
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 に答える