怎样用注解的方式配置 Spring?

答案解析

通过在类上加 @Component 或其派生注解(@Service、@Repository、@Controller),用 @Autowired 注入依赖,结合组件扫描实现自动装配。