11 2021 档案
摘要:在service实现类中添加注解 @Transactional在启动类中添加允许事务管理注解 @EnableTransactionManagement效果:即使在对数据操作中出现了异常,也不会更改数据库,调用回滚。
阅读全文
摘要:@Around("aspect()")public void around(JoinPoint joinPoint){ //获取目标类 Object target = joinPoint.getTarget().getClass().getName(); System.out.println(tar
阅读全文
摘要:import org.aspectj.lang.JoinPoint;import org.aspectj.lang.annotation.After;import org.aspectj.lang.annotation.Aspect;import org.aspectj.lang.annotatio
阅读全文
摘要:AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();context.scan("com.example");context.refresh();类中添加注解@component("
阅读全文
摘要:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
阅读全文
摘要:import java.lang.reflect.InvocationHandler;import java.lang.reflect.Method;import java.lang.reflect.Proxy;public class JDKProxy implements InvocationH
阅读全文
摘要:<!-- 通过名称自动注入<bean id="videoOrder" class="com.example.demo01.domain.VideoOrder" autowire="byName"> --> <!-- 通过类型自动注入 <bean id="videoOrder" class="com.
阅读全文
摘要:parent属性:只是复用依赖的bean中的属性,并不是Java中的继承。 <bean id="video" class="com.example.demo01.domain.Video" scope="singleton"> <property name="id" value="25"/> <pr
阅读全文
摘要:<bean id="test" class="com.example.demo01.domain.Test"><!--注入list--> <property name="list"> <list> <value>spring</value> <value>spring boot</value> <v
阅读全文
摘要:<bean id="video" class="com.example.demo01.domain.Video"> <constructor-arg name="title" value="spirng title"/> <constructor-arg name="id" value="8"/><
阅读全文
摘要:常见的属性有两种: singleton:单例,默认值,调用getBean方法返回同一个对象。 prototype:多例,调用getBean方法返回不同的对象。
阅读全文
摘要:在配置文件applicationContext.xml中: bean 中使用ref如下代码 <bean id="video" class="com.example.demo01.domain.Video"> <property name="id" value="25"/> <property nam
阅读全文
摘要:再resource目录下创建applicationContext.xml文件 文件代码 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xs
阅读全文
摘要:配置文件xml中事务管理的形式有两种 上代码: <environments default="development"> <environment id="development"> <!--指定事务管理的类型,这里简单使用Java的JDBC的提交和回滚设置--><!-- <transactionM
阅读全文
摘要:老方法: 配置文件添加配置 <settings> <!--如果要使用懒加载,就必须配置这两个属性--> <setting name="lazyLoadingEnabled" value="true"/> <setting name="aggressiveLazyLoading" value="fal
阅读全文
摘要:在配置文件加代码 <settings> <!--这个配置使全局的映射器(二级缓存)启用或禁用缓存,全局总开关,这里关闭,mapper中开启了也没用--> <setting name="cacheEnabled" value="true"/></settings>在需要使用二级缓存的xml文件中添加:
阅读全文
摘要:<resultMap id="UserOrderResultMap" type="User"> <id property="id" column="user_id"/> <result property="name" column="name"/> <result property="psw" co
阅读全文
摘要:<mapper namespace="接口路径"> <resultMap id="名称1" type="映射类名"> <id column="id" property="id"/> <result column="user_id" property="userId"/> <result column
阅读全文
摘要:原本的sql语句执行:select * from 表单 ,这种方式会获取表中所有字段,项目大时会特别的慢<select id="selectById" resultType="Video" parameterType="INTEGER"> select * from video where id=#
阅读全文
摘要:在mybatis的配置文件中添加 <typeAliases><!-- <typeAlias type="com.example.demo01.domain.Video" alias="Video"/>--> //让类取别名 一个个配置,如果有很多个类,可以使用下面这行,包扫描 <package na
阅读全文
摘要:<!--删除一条数据--><delete id="方法名" parameterType="<!--传入一个MAP-->java.util.Map" > delete from video where title like concat('%',#{title},'%') and price <
浙公网安备 33010602011771号