springboot
lanxing_thk
专注于当下,保持敬畏
展开
-
SpringBoot项目处理循环依赖问题(circular reference)
文章目录1 问题2 解决方法3 悔恨1 问题springBoot启动失败,报错BeanCurrentlyInCreationExceptionorg.springframework.beans.factory.BeanCurrentlyInCreationException:Error creating bean with name 'AxxxxService': Bean with name 'BxxxxService' has been injected into other beans原创 2021-12-07 22:26:45 · 2057 阅读 · 0 评论 -
Springboot插入数据报错:org.hibernate.MappingException:Unknown entity
文章目录1 问题2 解决1 问题通过dao插入entity时,报错org.hibernate.MappingException:Unknown entity2 解决增加注解 @EntityScan([“com.lan.*”]),扫描entity所在包即可原创 2021-10-07 21:43:20 · 566 阅读 · 0 评论 -
spring cache指定过期时间(redis)
文章目录1 问题:希望@Cacheable缓存根据名称指定失效时间2 增加配置类即可3 多个缓存分别设置时间1 问题:希望@Cacheable缓存根据名称指定失效时间@Cacheable(value=“cacheName”)2 增加配置类即可package com.sap.earl.apigateway.configimport org.springframework.beans.factory.annotation.Autowiredimport org.springframework.be原创 2021-09-11 20:33:26 · 3215 阅读 · 0 评论 -
IDEA中出现java file outside of source root
文章目录1 出现这个问题的原因2 解决方式3 我这边产生原因1 出现这个问题的原因由于项目提交以下三个文件夹到git上/build//.idea//.gradle/于是本地删除了一遍,重新提交回到idea看项目,所有src都找不到了2 解决方式idea右下角,有一个小弹窗:发现Gradle项目,是否导入点击确认后,项目复原3 我这边产生原因之所以会找到这里,是想刷新一下build.gradle, 但发现在删除了文件夹后,idea已经不知道这个项目是gradle项目,需要手动原创 2021-08-24 06:52:07 · 1300 阅读 · 0 评论 -
Springboot连接mysql数据库(springData)
文章目录1 代码调用2 数据库配置3 gradle 引用1 代码调用crud方法调用 继承功能类及自定义相关属性查询实体类声明注:如果表名与entity不一致(不是bet_record),使用@Table声明表名2 数据库配置application.yml文件spring: datasource: url: jdbc:mysql://localhost:3306/bet?useUnicode=true&characterEncoding=utf-8 pas原创 2021-08-17 08:14:57 · 279 阅读 · 0 评论 -
Springboot连接mysql数据库(jdbcTemplate)
1 代码调用2 数据库配置spring: datasource: url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false driverClassName: com.mysql.cj.jdbc.Driver username: root password: root3 gradle 引用implementation gro原创 2021-05-31 08:18:51 · 250 阅读 · 0 评论 -
aop after报错事务会回滚
@Transactional @GetMapping("/add") public String insert(@ModelAttribute Person model) throws Exception { model.setBirthday(new Date()); jdbcTemplate.update("insert into stu(name,birthday) values(?,?)",model.getName(),model.getBirth.原创 2021-05-17 22:46:50 · 870 阅读 · 0 评论 -
SpringBoot项目中,拦截器获取Post方法的请求body
SpringBoot项目中,拦截器获取Post方法的请求body一、遇到的问题二、解决方法1. 创建HttpServletRequest包装类(继承HttpServletRequestWapper类)2.创建过滤器(Filter),对request进行包装3. 通过流(inputStream)获取字符串的工具类4. 拦截器中获取body数据三、总结1. 原理上目前的理解2. 流的本质其实还是只能读...原创 2019-01-29 11:46:46 · 17358 阅读 · 15 评论