SSM常用注解与结构

Mybatis:(一级缓存与二级缓存)

注解:@param

<select id="" parameterType="" resultType="" resultMap="">
    ....select,update,insert,delete
</select>

一对多与多对一:

<resultMap id="" type="">
    <result property="" column=""></result>
    <!--多对一-->
    <association property="" javaType="">
        <result property="" column=""></result>
    </association>
    <!--一对多-->
    <collection property="" ofType="">
        <result property="" column=""></result>
    </collection>
</resultMap>

获取值的几种方式:

getxxx(p1,p2)
<select>
#{0} #{1}
</select>

getxxx(p1)
<select>
#{p1}
</select>

getxxx(HashMap)
<select>
#{key}
</select>

getxxx(User user)
<select>
#{name}
</select>

getxxx(@Param("p2") p1)
<select>
#{p2}
</select>

 

Spring:(bean的生命周期,后置处理器,工厂bean)

IOC 常用注解:

@Component,@Controller,@Service,@Repository

@Autowired,@Qualifier,@Resource,@Value

@Scope("singleton或prototype")

 

AOP 常用注解:

@Component,@Aspect,@Order(0) 数字越小优先级越高

@Pointcut(value="execution()"),@Before,@AfterReturning,@AfterThrowing,@After,@Around

可以获取到的参数:JoinPoint,ProceedingJoinPoint

1.Joinpoint:

Signature getSignature():获取封装了署名信息的对象,在该对象中可以获取到目标方法名,所属类的Class等信息

Object[] getArgs();获取传入目标方法的参数对象

Object getTarget();获取被代理的对象(对象的声明类型)

Object getThis();获取代理对象(对象的实例类型)

2.ProceedingJoinpoint:

只能用在around通知里

Object proceed() throws Throwable:执行目标方法

Object proceed(Object[] var1) throws Throwable:传入参数执行目标方法

连接点:可以被增强的方法,切入点:实际被正真增强的方法,通知:实际增强的逻辑部分

 

声明式事务常用注解:

@Transactional 可以添加到类上或方法上

脏读:一个事务读取到另外一个事务未提交的数据

不可重复读:同一个事务多次读取数据 读取到的结果都是一样的,表示读取不到其它

事务已提交的更新数据

可重复读:同一个事务多次读取数据 读取到的结果可能不一样,表示读取不到其它

事务已提交的更新数据

幻读:一个事务读取到另外一个事务已提交的插入数据

 

SpringMvc常用注解:(Request域 Sessiob域 Appliction域,拦截器)

@RequestMapping,@GetMapping,@PostMapping,@PathVariable

@RequestParam,@CookieValue,@RequestAttribute,@RequestHeader

@SessionAttributes

@ModelAttribute

@RequestBody,@RequestEntity,@ResponseBody,@ResponseEntity

@ControllerAdvice,@ExceptionHandler

posted on 2022-12-16 17:58  每天积极向上  阅读(21)  评论(0编辑  收藏  举报

导航