11 2021 档案

摘要:在service实现类中添加注解 @Transactional在启动类中添加允许事务管理注解 @EnableTransactionManagement效果:即使在对数据操作中出现了异常,也不会更改数据库,调用回滚。 阅读全文
posted @ 2021-11-30 14:41 智慧搬运工 阅读(178) 评论(0) 推荐(0)
摘要:@Around("aspect()")public void around(JoinPoint joinPoint){ //获取目标类 Object target = joinPoint.getTarget().getClass().getName(); System.out.println(tar 阅读全文
posted @ 2021-11-28 21:30 智慧搬运工 阅读(133) 评论(0) 推荐(0)
摘要:import org.aspectj.lang.JoinPoint;import org.aspectj.lang.annotation.After;import org.aspectj.lang.annotation.Aspect;import org.aspectj.lang.annotatio 阅读全文
posted @ 2021-11-28 15:17 智慧搬运工 阅读(88) 评论(0) 推荐(0)
摘要:AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();context.scan("com.example");context.refresh();类中添加注解@component(" 阅读全文
posted @ 2021-11-27 20:51 智慧搬运工 阅读(36) 评论(0) 推荐(0)
摘要:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance 阅读全文
posted @ 2021-11-27 14:49 智慧搬运工 阅读(132) 评论(0) 推荐(0)
摘要:import java.lang.reflect.InvocationHandler;import java.lang.reflect.Method;import java.lang.reflect.Proxy;public class JDKProxy implements InvocationH 阅读全文
posted @ 2021-11-26 22:41 智慧搬运工 阅读(88) 评论(0) 推荐(0)
摘要:<!-- 通过名称自动注入<bean id="videoOrder" class="com.example.demo01.domain.VideoOrder" autowire="byName"> --> <!-- 通过类型自动注入 <bean id="videoOrder" class="com. 阅读全文
posted @ 2021-11-25 21:21 智慧搬运工 阅读(46) 评论(0) 推荐(0)
摘要:parent属性:只是复用依赖的bean中的属性,并不是Java中的继承。 <bean id="video" class="com.example.demo01.domain.Video" scope="singleton"> <property name="id" value="25"/> <pr 阅读全文
posted @ 2021-11-25 16:28 智慧搬运工 阅读(51) 评论(0) 推荐(0)
摘要:<bean id="test" class="com.example.demo01.domain.Test"><!--注入list--> <property name="list"> <list> <value>spring</value> <value>spring boot</value> <v 阅读全文
posted @ 2021-11-25 00:07 智慧搬运工 阅读(221) 评论(0) 推荐(0)
摘要:<bean id="video" class="com.example.demo01.domain.Video"> <constructor-arg name="title" value="spirng title"/> <constructor-arg name="id" value="8"/>< 阅读全文
posted @ 2021-11-23 23:48 智慧搬运工 阅读(262) 评论(0) 推荐(0)
摘要:常见的属性有两种: singleton:单例,默认值,调用getBean方法返回同一个对象。 prototype:多例,调用getBean方法返回不同的对象。 阅读全文
posted @ 2021-11-23 23:22 智慧搬运工 阅读(42) 评论(0) 推荐(0)
摘要:在配置文件applicationContext.xml中: bean 中使用ref如下代码 <bean id="video" class="com.example.demo01.domain.Video"> <property name="id" value="25"/> <property nam 阅读全文
posted @ 2021-11-23 23:11 智慧搬运工 阅读(67) 评论(0) 推荐(0)
摘要:再resource目录下创建applicationContext.xml文件 文件代码 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xs 阅读全文
posted @ 2021-11-22 23:12 智慧搬运工 阅读(106) 评论(0) 推荐(0)
摘要:配置文件xml中事务管理的形式有两种 上代码: <environments default="development"> <environment id="development"> <!--指定事务管理的类型,这里简单使用Java的JDBC的提交和回滚设置--><!-- <transactionM 阅读全文
posted @ 2021-11-22 21:40 智慧搬运工 阅读(34) 评论(0) 推荐(1)
摘要:老方法: 配置文件添加配置 <settings> <!--如果要使用懒加载,就必须配置这两个属性--> <setting name="lazyLoadingEnabled" value="true"/> <setting name="aggressiveLazyLoading" value="fal 阅读全文
posted @ 2021-11-22 17:19 智慧搬运工 阅读(122) 评论(0) 推荐(0)
摘要:在配置文件加代码 <settings> <!--这个配置使全局的映射器(二级缓存)启用或禁用缓存,全局总开关,这里关闭,mapper中开启了也没用--> <setting name="cacheEnabled" value="true"/></settings>在需要使用二级缓存的xml文件中添加: 阅读全文
posted @ 2021-11-21 22:46 智慧搬运工 阅读(191) 评论(0) 推荐(0)
摘要:<resultMap id="UserOrderResultMap" type="User"> <id property="id" column="user_id"/> <result property="name" column="name"/> <result property="psw" co 阅读全文
posted @ 2021-11-21 16:55 智慧搬运工 阅读(926) 评论(0) 推荐(0)
摘要:<mapper namespace="接口路径"> <resultMap id="名称1" type="映射类名"> <id column="id" property="id"/> <result column="user_id" property="userId"/> <result column 阅读全文
posted @ 2021-11-21 16:11 智慧搬运工 阅读(67) 评论(0) 推荐(0)
摘要:原本的sql语句执行:select * from 表单 ,这种方式会获取表中所有字段,项目大时会特别的慢<select id="selectById" resultType="Video" parameterType="INTEGER"> select * from video where id=# 阅读全文
posted @ 2021-11-20 16:16 智慧搬运工 阅读(231) 评论(0) 推荐(0)
摘要:在mybatis的配置文件中添加 <typeAliases><!-- <typeAlias type="com.example.demo01.domain.Video" alias="Video"/>--> //让类取别名 一个个配置,如果有很多个类,可以使用下面这行,包扫描 <package na 阅读全文
posted @ 2021-11-20 15:50 智慧搬运工 阅读(37) 评论(0) 推荐(0)
摘要:<!--删除一条数据--><delete id="方法名" parameterType="<!--传入一个MAP-->java.util.Map" > delete from video where title like concat('%',#{title},'%') and price <![C 阅读全文
posted @ 2021-11-19 23:37 智慧搬运工 阅读(94) 评论(0) 推荐(0)
摘要:<!--动态字段更新 if test 标签使用--><update id="方法名" parameterType="类对象的路径"> update video <trim prefix="set" suffixOverrides=","> <if test="title != null">title 阅读全文
posted @ 2021-11-19 21:49 智慧搬运工 阅读(480) 评论(0) 推荐(0)
摘要:<update id="接口的方法名" parameterType="类对象的路径">//sql语句 update video set title=#{title,jdbcType=VARCHAR}, detail=#{detail,jdbcType=VARCHAR}, cover_img=#{co 阅读全文
posted @ 2021-11-19 11:28 智慧搬运工 阅读(83) 评论(0) 推荐(0)
摘要:在xml文件中添加红框代码 keyProperty指数据库表中的自增主键 keyColum指映射的类中的属性名称 上代码: <insert id="add" parameterType="com.example.demo01.domain.Video" useGeneratedKeys="true" 阅读全文
posted @ 2021-11-19 10:34 智慧搬运工 阅读(131) 评论(0) 推荐(0)
摘要:mybatis配置文件内代码 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybat 阅读全文
posted @ 2021-11-18 23:06 智慧搬运工 阅读(52) 评论(0) 推荐(0)