Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
サービス X と Y があります。X 内で Y を呼び出したい場合は、注釈を使用してそれを行う方法はありますか。他のすべてのリソースは X に対して Autowired であるため、X/Y の Bean を構成したくありません。
ありがとう!
Spring はマネージド インスタンスのみを注入できます。
@Service public class X { @Resource private Y y; } @Service public class Y { }
@Service をクラス Y に追加したくない場合は、これを使用できます (X は同じです)。
@Configuration public class AppConfig { @Bean public Y y { return new Y(); } }