Spring Beans
@ComponentScan 扫描指定包下的@Component @Controller @Service @Respository类
@Autowired 自动注入bean,可以在属性/构造方法/set方法上使用
package com.example.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class DatabaseAccountService implements AccountService { private final RiskAssessor riskAssessor; @Autowired public DatabaseAccountService(RiskAssessor riskAssessor) { this.riskAssessor = riskAssessor; } // ... }