Spring注解
@ServletComponentScan
扫描【@WebServlet、@WebFilter、@WebListener】:
// Enables scanning for Servlet components
Servlet、Filter、Listener可以直接通过@WebServlet、@WebFilter、@WebListener注解自动注册。
@EnableAutoConfiguration
开启自动化配置
@ComponentScan
扫描【@Component】:
@Configuration、@Controller、@Service等包含@Component,也会被扫描
@Configuration
声明被注解的类是配置类,一般配合@Bean使用,用来将自定义的bean注入容器
@Autowired
根据类型装配,如果容器中有两个相同类型的bean,则会抛出异常。
Mybatis注解
@Mapper
思考:被@mapper注解的DAO层是怎样注入Spring容器的?
本文详细解析了Spring框架中关键注解的功能与用法,包括@ServletComponentScan、@EnableAutoConfiguration、@ComponentScan、@Configuration和@Autowired。同时,深入探讨了Mybatis框架中@Mapper注解的作用及其实现机制。

5122

被折叠的 条评论
为什么被折叠?



