1、日志级别配置
可以为不同包路径下的代码,配置不同级别的日志输出级别
对整个项目配置级别:logging.level.root=debug
对某个路径下的代码配置级别:logging.level.包路径=debug可以查看相关网站,查看如何使用自定义配置文件进行日志的其他设置
输出事务控制日志:logging.level.org.springframework.transaction=trace
其他相关包:
logging.level.org.springframework.orm.jpa=debug
logging.level.org.springframework.jdbc=debug
2、AOP代理
spring.aop.auto=true
等效于在springboot启动类上加注解: @EnableAspectJAutoProxy.
spring.aop.proxy-target-class=true
默认使用CGLIB创建动态代理Whether subclass-based (CGLIB) proxies are to be created (true), as opposed to standard Java interface-based proxies (false).
详见 讨论
springboot中,切面的代理实现形式由全局配置项spring.aop.proxy-target-class控制。因为spring.aop.proxy-target-class参数默认为true,所以对于所有需要基于spring创建动态代理来管理的bean,默认使用cglib创建动态代理。与spring的代理创建默认机制不同,见原因 二.4.1。
我对需要事务控制的代理的类型进行了测试,无论被代理类是否实现了接口:
当全局配置项spring.aop.proxy-target-class为
true,产生cglib的代理;
false或empty为空时,代理类型由@EnableAspectJAutoProxy, @EnableAsync, @EnableCaching,和@EnableTransactionManagement四者的proxyTargetClass共同决定^摘自springboot讨论==,只要有任意一项指定proxyTragetClass=true,则会使用CGLIB创建事务的动态代理。若都为false,则产生jdk动态代理。(看上去就像springboot会忽略注解属性的false,只有true有效)