fix:redis 测试

上级 8574a410
......@@ -244,6 +244,11 @@
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
......
package com.kwan.springbootkwan.controller;
import com.kwan.springbootkwan.entity.Result;
import com.kwan.springbootkwan.service.IExcelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* excel测试信息
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/11/17 09:04
*/
@Slf4j
@Api(value = "excel测试信息", tags = "ExcelController")
@RestController
@RequestMapping("/test")
public class ExcelController {
@Resource
private IExcelService excelService;
@ApiOperation(value = "下载excel", notes = "下载excel")
@GetMapping("/downloadExcel")
public Result downloadExcel() {
// excelService.downloadExcel();
return Result.ok();
}
}
package com.kwan.springbootkwan.service;
public interface IExcelService {
}
package com.kwan.springbootkwan.service.impl;
import com.kwan.springbootkwan.service.IExcelService;
import org.springframework.stereotype.Service;
@Service
public class IExcelServiceImpl implements IExcelService {
}
package com.kwan.springbootkwan.utils;
import com.kwan.springbootkwan.entity.User;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ExcelWriter {
private static List<String> header = Arrays.asList("1");
public static void writeListToExcel(List<User> dataList, String filePath, String sheetName) {
try (Workbook workbook = new XSSFWorkbook()) {
Sheet sheet = workbook.createSheet(sheetName);
// 创建标题行
Row headerRow = sheet.createRow(0);
for (int i = 0; i < dataList.size(); i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue("季节");
}
// 写入数据行
int rowNum = 1;
for (Object data : dataList) {
Row row = sheet.createRow(rowNum++);
CellStyle style = workbook.createCellStyle();
style.setWrapText(true);
Cell cell = row.createCell(0);
cell.setCellValue(data.toString());
cell.setCellStyle(style);
}
// 将Workbook写入文件
try (FileOutputStream fileOut = new FileOutputStream(filePath)) {
workbook.write(fileOut);
}
System.out.println("Excel文件成功创建!");
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
// 你的数据列表
List<User> dataList = new ArrayList<>();
User user1 = new User();
user1.setId(1);
user1.setName("张三");
user1.setSex("男");
dataList.add(user1);
User user2 = new User();
user2.setId(2);
user2.setName("程满");
user2.setSex("女");
dataList.add(user2);
User user3 = new User();
user3.setId(3);
user3.setName("禹辰");
user3.setSex("男");
dataList.add(user3);
// Excel文件路径和工作表名称
String filePath = "/Users/qinyingjie/Downloads/file.xlsx";
String sheetName = "Sheet1";
// 调用写入Excel的方法
writeListToExcel(dataList, filePath, sheetName);
}
}
......@@ -15,9 +15,10 @@ spring:
required: true
redis:
database: 0 # Redis数据库索引(默认为0)
host: 120.79.36.53 #Redis服务器地址
# host: 43.139.90.182 #Redis服务器地址
host: 47.94.110.103 #Redis服务器地址
port: 6379 # Redis服务器连接端口
password: 123456 # Redis服务器连接密码(默认为空)
password: zzk # Redis服务器连接密码(默认为空)
jedis:
pool:
max-active: 200 # 连接池最大连接数(使用负值表示没有限制)
......@@ -32,15 +33,15 @@ spring:
kwan-ds:
driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://120.79.36.53:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://43.139.90.182:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
# password: 716288qwe
password: 15671628341Qwe.
password: 123456
ali-ds:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://120.79.36.53:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://43.139.90.182:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 15671628341Qwe.
password: 123456
# jasypt加密的密匙
jasypt:
encryptor:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册