@autowiredというアノテーションが付けられたこの特定のクラスのメンバープライベートフィールドは、サービスJAR内にあり、コード内でクラスのインスタンスを取得しようとすると、@ autowiredメンバーは常にヌル。 JAR内のベースパッケージを検索しようとしているプロジェクトのcontext.xml内に以下のコンポーネントスキャンステートメントがありますが、nullが注釈付きメンバーに注入されているようです。 JARは内部的にcontext.xmlも持っていますが、これは以下のコンポーネントスキャンエントリと同じです。 JARソースコードは今変更できません。欠けているものはありますか?スプリング@autowiredがnullを返す
<!-- local WEB-INF/spring-context/spring-application-context.xml -->
<context:annotation-config />
<context:component-scan base-package="blah.blah" />
//this code within my project
//wjc.getMethod() dereferencing comes back null
public class A{
WithinJARInterface wjc = new WithinJARInterfaceImpl()
List someObject = wjc.getMethod()
}
//this code interface within JAR
public interface WithinJARInterface{
public List getMethod() throws Exception();
}
//this code within JAR
public class WithinJARInterfaceImpl implements WithinJARInterface{
//below member always comes back NULL
@Autowired
private JARService jService;
public List getMethod(){.....}
}
public interface JARService{
public List method1();
}
@Service("JARService")
public class JARServiceImpl implments JARService {
public List method1(){ }
}
'@ Autowired'でアノテーションされた' null'フィールドを持つオブジェクトはどうやって取得しますか?コードを表示します。 –
私は質問を更新しました – Noosphere
それはたぶん質問の誤字ですが、注釈は '@ Autowired'(大文字のA)です。 - これが質問のタイプミスでない場合は、問題の根源になる可能性があります。 – Ralph