春の豆と依存性注入 - 春ブーツを使用します

春の豆

  パケットスキャンで指定@Component @Controller @Service @Respositoryクラス@ComponentScan

  あなたのプロパティ/コンストラクタ/ setメソッドで、Beanを自動的に注入し@Autowired

 

  

パッケージcom.example.service。

輸入org.springframework.beans.factory.annotation.Autowired;
輸入org.springframework.stereotype.Service。

@Service 
パブリック クラス DatabaseAccountServiceは実装AccountServiceの{ 

    民間 最終RiskAssessor riskAssessorを。

    @Autowired 
    公共DatabaseAccountService(RiskAssessor riskAssessor){
         この .riskAssessor = riskAssessor。
    } 

    // ... 

}

 

おすすめ

転載: www.cnblogs.com/han6/p/11531955.html