Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
539fc5af
S
SpringBoot-kwan
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
SpringBoot-kwan
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SpringBoot-kwan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
539fc5af
编写于
11月 29, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:redis 测试
上级
8574a410
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
142 addition
and
6 deletion
+142
-6
pom.xml
pom.xml
+5
-0
src/main/java/com/kwan/springbootkwan/controller/ExcelController.java
...a/com/kwan/springbootkwan/controller/ExcelController.java
+37
-0
src/main/java/com/kwan/springbootkwan/service/IExcelService.java
...n/java/com/kwan/springbootkwan/service/IExcelService.java
+9
-0
src/main/java/com/kwan/springbootkwan/service/impl/IExcelServiceImpl.java
...m/kwan/springbootkwan/service/impl/IExcelServiceImpl.java
+8
-0
src/main/java/com/kwan/springbootkwan/utils/ExcelWriter.java
src/main/java/com/kwan/springbootkwan/utils/ExcelWriter.java
+76
-0
src/main/resources/application-local.yml
src/main/resources/application-local.yml
+7
-6
未找到文件。
pom.xml
浏览文件 @
539fc5af
...
@@ -244,6 +244,11 @@
...
@@ -244,6 +244,11 @@
<artifactId>
gson
</artifactId>
<artifactId>
gson
</artifactId>
<version>
2.10.1
</version>
<version>
2.10.1
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
4.1.2
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
src/main/java/com/kwan/springbootkwan/controller/ExcelController.java
0 → 100644
浏览文件 @
539fc5af
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
();
}
}
src/main/java/com/kwan/springbootkwan/service/IExcelService.java
0 → 100644
浏览文件 @
539fc5af
package
com.kwan.springbootkwan.service
;
public
interface
IExcelService
{
}
src/main/java/com/kwan/springbootkwan/service/impl/IExcelServiceImpl.java
0 → 100644
浏览文件 @
539fc5af
package
com.kwan.springbootkwan.service.impl
;
import
com.kwan.springbootkwan.service.IExcelService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
IExcelServiceImpl
implements
IExcelService
{
}
src/main/java/com/kwan/springbootkwan/utils/ExcelWriter.java
0 → 100644
浏览文件 @
539fc5af
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
);
}
}
src/main/resources/application-local.yml
浏览文件 @
539fc5af
...
@@ -15,9 +15,10 @@ spring:
...
@@ -15,9 +15,10 @@ spring:
required
:
true
required
:
true
redis
:
redis
:
database
:
0
# Redis数据库索引(默认为0)
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服务器连接端口
port
:
6379
# Redis服务器连接端口
password
:
123456
# Redis服务器连接密码(默认为空)
password
:
zzk
# Redis服务器连接密码(默认为空)
jedis
:
jedis
:
pool
:
pool
:
max-active
:
200
# 连接池最大连接数(使用负值表示没有限制)
max-active
:
200
# 连接池最大连接数(使用负值表示没有限制)
...
@@ -32,15 +33,15 @@ spring:
...
@@ -32,15 +33,15 @@ spring:
kwan-ds
:
kwan-ds
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
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://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
username
:
root
# password: 716288qwe
# password: 716288qwe
password
:
1
5671628341Qwe.
password
:
1
23456
ali-ds
:
ali-ds
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
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
username
:
root
password
:
1
5671628341Qwe.
password
:
1
23456
# jasypt加密的密匙
# jasypt加密的密匙
jasypt
:
jasypt
:
encryptor
:
encryptor
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录