私は本当にこの1つに固執しています...ヘルプ! :)<jee:jndi-lookupデフォルト値とクラスパスの使用
私はj2ee:jndiルックアップをプロパティファイルに使用しています。以下では正常に動作します:
<bean class="org.springframework.core.io.FileSystemResource">
<constructor-arg>
<jee:jndi-lookup id="myProps" jndi-name="myProps" resource-ref="true" />
</constructor-arg>
</bean>
はしかし、私は、JNDIルックアップが失敗した場合に対処したいが、WEB-INF/classesフォルダにあるデフォルトのファイルにフォールバックします。しかし
<bean class="org.springframework.core.io.FileSystemResource">
<constructor-arg>
<jee:jndi-lookup id="myProps" jndi-name="myProps" resource-ref="true"
default-value="classpath:myprops.properties" />
</constructor-arg>
</bean>
、Iハードコードデフォルト値のための特定のパスの場合:私は以下のようにデフォルト値を使用している場合、Webアプリケーションは、ファイル「myprops.propertiesクラスパス」を見つけることができないことを訴えて例外がスローされます、それは正常に動作しますが、それは最終的な解決策として受け入れられません。
私の問題は「classpath:」を使って正しく解決されるようにすることです。
これは私が使用しています全体的な使い方です:
<bean id="authServerProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"/>
<property name="location">
<bean class="org.springframework.core.io.FileSystemResource">
<constructor-arg>
<jee:jndi-lookup id="myProps" jndi-name="myProps" resource-ref="true"
default-value="classpath:myprops.properties" />
</constructor-arg>
</bean>
</property>
.....
</bean>