2017-05-15 3 views
0

Spring(4.3.8)管理対象クラスを含む従来の製品のJARがあります。 CDI(JavaEE 7)と統合する必要があります。工場で作成されたインスタンスの場合でも、SpringがCDI注釈を干渉するのを防ぐ

私はレガシーJARからのインターフェースを持っています。これはCDI Beanによって実装されています。 CDI BeanはCDI BeanManagerから要求され、ファクトリメソッドから返されます。ファクトリメソッドはSpring XMLに登録され、期待どおりに動作します。

レガシーJARのSpring Beanが実装されたインタフェースに依存する場合、問題が発生します。 SpringはCDIインプリメンテーション・インスタンスをインジェクトし、既知のアノテーションのクラスを@Injectという名前でスキャンします。次に、依存関係を解決しようとします。これは、依存関係がSpringに利用できないため機能しません。

私は既にコンテキストを調整しました:property-placeholder excludes、しかしそれは何も変わりません。

私は工場で生産されたbeanインスタンスに何かを注入しようとするのを止めるようにSpringにどのように伝えることができますか?

答えて

0

私はようやく問題を解決することができました。レガシーJARのすべてのCDIアノテーションを削除する必要がありました。

は、その後、私は私のCDIのWARのapplicationContext.xmlをに次のXMLブロックを追加しました:

<context:component-scan annotation-config="false" base-package="com.example"> 
</context:component-scan> 
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"> 
    <property name="autowiredAnnotationTypes"> 
     <set> 
      <value>org.springframework.beans.factory.annotation.Autowired</value> 
      <value>org.springframework.beans.factory.annotation.Value</value> 
     </set> 
    </property> 
</bean> 
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" /> 
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> 
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" /> 
<bean class="org.springframework.beans.factory.annotation.CustomAutowireConfigurer"> 
    <property name="customQualifierTypes"> 
     <set> 
      <value>org.springframework.beans.factory.annotation.Qualifier</value> 
     </set> 
    </property> 
</bean> 

基本的にそれは春からなど@Injectのサポートをドロップし、それが属するところそれを残し:CDIを。

関連する問題