2017-06-07 6 views
0

私の春のブートアプリケーションでは、アノテーションベースの設定とWebApplicationInitalizerを使用しています。依存関係jar内のapplication-context.xmlのSpringプロパティプレースホルダ

私の依存関係の1つは、jarに含まれているxmlに春の構成を提供します。私は@ImportResourceを使ってコンテキストXMLを読み込みます。これは、このXML内で、プロパティプレースホルダがあるという事実を除いて、動作しているようです例えば${poolsize:10}

どうやら、春は自動的に(私はNumberFormatExceptionを取得)これらのプレースホルダに代わるものではありません。追加する必要のある追加の設定はありますか?

当社の起動クラス:

public class Application implements WebApplicationInitializer { 

    @Override 
    public void onStartup(ServletContext container) throws ServletException { 
     // Create the 'root' Spring application context 
     AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); 

     // config 
     rootContext.register(JmsConfiguration.class); 

     // Manage the lifecycle of the root application context 
     container.addListener(new ContextLoaderListener(rootContext)); 
    } 

} 

およびコンフィギュレーションクラス(私たちは春-JMSを使用):

@Configuration 
@EnableJms 
@ComponentScan(basePackages = { "..." }) 
public class JmsConfiguration implements JmsListenerConfigurer { 
     // config for jms listener and jaxb, nothing to do with property handling 
} 

おそらく、私はWebapplicationInitializerを使用して、スプリングを使用する方法であることを考えで間違ってんですブート。おそらく、春のブーツは必要ないでしょうか?我々が使用依存性を関連のみ春のブートは次のとおりです。我々が使用

<dependency> 
    <!-- Import dependency management from Spring Boot --> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-dependencies</artifactId> 
    <version>1.5.3.RELEASE</version> 
    <type>pom</type> 
    <scope>import</scope> 
</dependency> 

春の依存関係:

org.springframework:spring-context:jar:4.3.8.RELEASE:compile 
org.springframework:spring-jms:jar:4.3.8.RELEASE:compile 
org.springframework:spring-oxm:jar:4.3.8.RELEASE:compile 
org.springframework:spring-context:jar:4.3.8.RELEASE:compile 
org.springframework:spring-beans:jar:4.3.8.RELEASE:compile 
+0

これはすぐに動作するはずです。もしそうでなければ、あなたはすでにあまりにも多くを追加したでしょう。あなたはSpring Bootを使用していますが、なぜ 'WebApplicationInitializer'が必要でしょうか?あなたがSpring Bootを使用しようとしているが、意図した方法ではないように見えます。 –

+0

ヘイマルテン、応答のおかげで。私は実際にあなたの古いアプリケーション(WSB)の1つで実際に作業しています:) この質問は、jboss EAP 6にデプロイしたい新しいアプリケーションです。私はいくつかのコードで質問を更新します。 – mrMario

答えて

0

私は感謝の@Mをそれを考え出しました。 Deinum

我々はPropertySourcesPlaceholderConfigurer私たち自身を宣言する必要が(少なくとも春ブーツなし)WebApplicationInitializerを使用するように春ブーツが必要ですが、ありません:

@Configuration 
@ImportResource(locations = {"classpath*:/library-context.xml"}) 
public class MyConfiguration { 

    @Bean 
    public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() { 
     return new PropertySourcesPlaceholderConfigurer(); 
    } 

} 

NB。 @EnableAutoConfiguration@PropertyPlaceholderAutoConfigurationのおかげで、春の起動時にすぐに動作します。PropertySourcesPlaceholderConfigurer bean

関連する問題