# Spring_study **Repository Path**: thread-git/Spring_study ## Basic Information - **Project Name**: Spring_study - **Description**: Spring Learning Process - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-06-11 - **Last Updated**: 2022-06-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 常用依赖 ```xml org.springframework spring-webmvc 5.2.0.RELEASE junit junit 4.12 ``` ## 注解 - @AutoWired:自动装配通过类型,名字 如果Autowired不能唯一自动装配上属性,则需要@Qualifier(value = "对象名") - @Nullable:表示该字段可以为空 @Autowired(required = false)作用一样 - @Resource:自动装配通过名字、类型 - @Component:放在类上,表示spring已接管这个类,是bean ###### MVC衍生注解 @Component有几个衍生注解,按照MVC三层架构分层 - @Controller Controller层 - @Repository Dao层 - @Service Service层 功能和@Component一样都是注册类到spring里,仅仅是为了分层。 ##spring-mybatis整合 spring-dao.xml ```xml ``` applicationContext.xml ```xml ``` mybatis-config.xml ```xml ``` UserMapperImpl.java ```java public class UserMapperImpl2 extends SqlSessionDaoSupport implements UserMapper { public List selectUser() { return getSqlSession().getMapper(UserMapper.class).selectUser(); } } ``` UserMapper.java ```java public interface UserMapper { List selectUser(); } ``` UserMapper.xml ```xml ```