2016-08-18 4 views
0

JBOSS 5.1.0.GAとSpring統合フレームワークを使用しています。設定ファイルをJBOSSのconfディレクトリの下に置いてクラスパスから読み込みます。しかし、今度は、すべての設定ファイルをconfディレクトリからwarファイルのWEB-INFディレクトリに移動する必要があると言われています。すべてがうまくいきましたconfディレクトリにファイルを置いたとき。WEB-INFディレクトリにファイルを配置して読み込み

<bean id="xyz" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
     <property name="locations"> 
      <list> 
       <value>classpath:CustomerService/property-files/*.properties</value>  
      </list> 
     </property> 
</bean> 

しかし、我々は、我々は例外java.io.FileNotFoundExceptionを取得している以下の変更を加えることで、confディレクトリからWEB-INFディレクトリに設定ファイルを移動します。

<bean id="xyz" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
     <property name="locations"> 
      <list> 
       <value>/WEB-INF/CustomerService/property-files/*.properties</value>  
      </list> 
     </property> 
</bean> 

例外の詳細:

java.io.FileNotFoundException: URL [jndi:/localhost/pqawdTestWebApp/WEB-INF/CustomerService/spring-integration/Jobs/] cannot be resolved to absolute file path because it does not reside in the file system: jndi:/localhost/pqawdTestWebApp/WEB-INF/CustomerService/spring-integration/Jobs/ 
    at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:205) 
    at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52) 
    at org.springframework.core.io.UrlResource.getFile(UrlResource.java:169) 
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:526) 

誰が何をすべきかのアイデアを持って?

答えて

0

WEB-INFディレクトリパスは、スタンドアロンSpringプロジェクトのクラスパスとして使用できません。だから、設定ファイルをsrc/resourcesフォルダに移動して、手間をかけずにインポートしました。

0

(いくつかのビルド手段によって)クラスパスに配置します。

/WEB-INF/classes/CustomerService/property-files/*.properties 
+0

これは問題ありません。しかし、web.xmlや他の春の設定ファイルからそれらを読み込む方法は?読むためにどこに指定する必要がありますか? –

+0

以前と同じように、 'classpath:CustomerService/property-files/...'(春)。それ以外の場合は、通常のリソースファイル、 'getResourceAsStream("/... ")'または何でも、 –

+0

つまり、WEB-INFフォルダの設定ファイルを読み込むためにスプリングBeanが必要です。私は正しいですか? –

関連する問題