zxpnet网站 zxpnet网站
首页
前端
后端服务器
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

zxpnet

一个爱学习的java开发攻城狮
首页
前端
后端服务器
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 大后端课程视频归档
  • 南航面试题
  • 并发编程

  • 性能调优

  • java8语法

  • lombok

  • 日志

  • 工具类

  • spring

  • mybatis

  • springboot

    • springboot基础篇
    • springboot配置文件yaml
    • springboot web开发
    • springboot数据访问
    • springboot单元测试
    • springboot性能监控actuator
    • SpringBoot 原理解析
    • spring.factories文件
    • springboot常用注解
    • springboot序列化
    • springboot整合swagger
    • Spring Boot 定制URL匹配规则的方法
    • springboot整合redisson分布式锁
    • springboot+线程池使用
    • springboot2应用中碰到的一些坑
      • 与操作系统有关
        • 1、CentOS7的/tmp目录自动清理规则
      • 版本问题
        • 2.4以上版本
      • 事务问题
    • SpringBoot面试题
  • redis

  • zookeeper

  • springcloud

  • dubbo

  • netty

  • springsecurity

  • mq消息中间件

  • shiro

  • beetle

  • 模板引擎

  • jpa

  • 数据结构与算法

  • 数据库知识与设计

  • gradle

  • maven

  • bus

  • 定时任务

  • docker

  • centos

  • 加解密

  • biz业务

  • pigx项目

  • 开源项目

  • 品达通用权限项目-黑马

  • 货币交易项目coin-尚学堂

  • php

  • backend
  • springboot
shollin
2021-06-23
目录

springboot2应用中碰到的一些坑

  • 与操作系统有关
    • 1、CentOS7的/tmp目录自动清理规则
  • 版本问题
    • 2.4以上版本
  • 事务问题

# 与操作系统有关

# 1、CentOS7的/tmp目录自动清理规则

  • 处理方式:改变临时文件的存储路径
/**
 * @date 2018-12-28
 * @author https://blog.csdn.net/llibin1024530411/article/details/79474953
 */
@Configuration
public class MultipartConfig {

    /**
     * 文件上传临时路径
     */
    @Bean
    MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        String location = System.getProperty("user.home") + "/.springboot2/file/tmp";
        File tmpFile = new File(location);
        if (!tmpFile.exists()) {
            tmpFile.mkdirs();
        }
        factory.setLocation(location);
        return factory.createMultipartConfig();
    }
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

SpringBoot项目的The temporary upload location ***is not valid 问题_llibin1024530411的博客-CSDN博客 (opens new window)

# 版本问题

# 2.4以上版本

1、SpringBoot升级2.4.0所出现的问题:When allowCredentials is true, allowedOrigins cannot contain the specia_jxysgzs的博客-CSDN博客 (opens new window)

2、序列化与反序列化版本冲突: stream classdesc serialVersionUID = 530, local class serialVersionUID = 540_Coverma的博客-CSDN博客 (opens new window)

# 事务问题

Spring的事务是通过代理对象去处理,如果在在同一个类里面, 编写两个方法, 内部调用的时候, 会导致事务设置失效。 原因是没有用到代理对象的缘故。 解决: 0) 、 导入 spring-boot-starter-aop 1) 、 @EnableTransactionManagement(proxyTargetClass = true) 2) 、 @EnableAspectJAutoProxy(exposeProxy=true) 3) 、 AopContext.currentProxy() 调用方法

@Transactional(propagation = Propagation.REQUIRED)
public void A(){
	bService.b();
	bService.c();
	
	// b()和C()方法上设置事务传播级别不会起作用,和A()共用一个事务
	b();
	c();
}
1
2
3
4
5
6
7
8
9
springboot+线程池使用
SpringBoot面试题

← springboot+线程池使用 SpringBoot面试题→

最近更新
01
国际象棋
09-15
02
成语
09-15
03
自然拼读
09-15
更多文章>
Theme by Vdoing | Copyright © 2019-2023 zxpnet | 粤ICP备14079330号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式