0

fc-jsf という名前のプロジェクトがあります。このプロジェクトのスプリング コンテキストは、fc-bus プロジェクトの Beans.xml という名前の別のスプリング コンテキストを参照します。fc-jsf のプロジェクト依存関係として fc-bus があります。

次のように Beans.xml をインポートします。

<import resource="classpath*:com/fc/spring/Beans.xml" />

動作していますが、fc-jsf プロジェクトは Beans.xml で宣言されたプロパティを認識できないと言われています。

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location">
            <value>com/fc/properties/database.properties</value>
        </property>
    </bean>

例外は次のとおりです。

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/com/fc/properties/database.properties]

プロパティ ファイルを fc-jsf プロジェクトにコピーせずに database.properties に到達する方法は?

編集: これらは Maven プロジェクトです。database.properties は fc-bus -> src/main/resurces/com/fc フォルダーにあります。

4

2 に答える 2

0

次のようなプロパティを使用してみてください

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
        <value>classpath:com/fc/properties/database.properties</value>
    </property>
</bean>

そうしないと、どのパッケージから使用する必要があるかわかりません

于 2013-03-23T14:00:37.620 に答える
0

試してみてください <value>classpath*:database.properties</value>

于 2013-03-23T14:01:23.487 に答える