在pom文件中引入依赖
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.10</version> <!-- 替换为最新版本 -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
配置文件
files:
upload:
path: D:/javae/Travelingdemo/file/
创建工具类
package com.example.travelingdemo.controller;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.example.travelingdemo.entity.Files;
import com.example.travelingdemo.mapper.FilesMapper;
import org.springframework.beans.factory.annotation.Autow