Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
f2a56f4c
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看板
提交
f2a56f4c
编写于
12月 20, 2022
作者:
Q
qinyingjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:概要
上级
74a5a03a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
112 addition
and
3 deletion
+112
-3
.gitignore
.gitignore
+0
-1
READ.md
READ.md
+43
-0
src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java
...est/java/com/kwan/springbootkwan/UserServiceImplTest.java
+69
-2
未找到文件。
.gitignore
浏览文件 @
f2a56f4c
READ.md
target/
target/
!.mvn/wrapper/maven-wrapper.jar
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/main/**/target/
...
...
READ.md
0 → 100644
浏览文件 @
f2a56f4c
## 一.说明
主要是SpringBoot学习
### 二.主要集成
-
redis
-
mybatis-plus
-
swagger2
-
logback
-
druid
-
@Aspect切面日志
-
devtools热部署
-
mapstruct dto-vo转换
-
test测试模块
-
mysql
-
web模块
-
发邮件
## 三.链接
### 1.访问链接
http://localhost:8761/user/all
### 2.swagger
http://localhost:8761/swagger-ui.html
src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java
浏览文件 @
f2a56f4c
...
@@ -8,6 +8,10 @@ import org.junit.jupiter.api.Test;
...
@@ -8,6 +8,10 @@ import org.junit.jupiter.api.Test;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
@SpringBootTest
@SpringBootTest
public
class
UserServiceImplTest
{
public
class
UserServiceImplTest
{
...
@@ -15,7 +19,7 @@ public class UserServiceImplTest {
...
@@ -15,7 +19,7 @@ public class UserServiceImplTest {
@Autowired
@Autowired
private
UserMapper
userService
;
private
UserMapper
userService
;
@Autowired
@Autowired
private
ISendMsgHandle
is
SendMsgHandle
;
private
ISendMsgHandle
email
SendMsgHandle
;
@Test
@Test
public
void
queryAll
()
{
public
void
queryAll
()
{
...
@@ -32,6 +36,69 @@ public class UserServiceImplTest {
...
@@ -32,6 +36,69 @@ public class UserServiceImplTest {
mailInfo
.
setReceiver
(
new
String
[]{
"qinyingjie@deepexi.com"
});
mailInfo
.
setReceiver
(
new
String
[]{
"qinyingjie@deepexi.com"
});
mailInfo
.
setSubject
(
"测试主题"
);
mailInfo
.
setSubject
(
"测试主题"
);
mailInfo
.
setContent
(
"邮件内容"
);
mailInfo
.
setContent
(
"邮件内容"
);
isSendMsgHandle
.
sendSimpleTextEmail
(
mailInfo
);
emailSendMsgHandle
.
sendSimpleTextEmail
(
mailInfo
);
}
/**
* 带html
*/
@Test
public
void
sendHTMLMail
()
{
MailInfo
mailBean
=
new
MailInfo
();
//接收人
mailBean
.
setReceiver
(
new
String
[]{
"qinyingjie@deepexi.com"
});
mailBean
.
setSubject
(
"SpringBootMailHTML之这是一封HTML格式的邮件"
);
//抄送给谁
mailBean
.
setCc
(
new
String
[]{
"786775527@qq.com"
,
"286968900@qq.com"
});
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"<h2>SpringBoot测试邮件HTML</h2>"
)
.
append
(
"<p style='text-align:left'>这是一封HTML邮件...</p>"
)
.
append
(
"<p> 时间为:"
+
new
Date
()
+
"</p>"
);
mailBean
.
setContent
(
sb
.
toString
());
//true、false控制以普通文本发送还是以html格式发送
emailSendMsgHandle
.
sendHtmlEmail
(
mailBean
,
true
);
}
@Test
void
sendEmail
()
{
MailInfo
mailBean
=
new
MailInfo
();
mailBean
.
setReceiver
(
new
String
[]{
"qinyingjie@deepexi.com"
});
mailBean
.
setSubject
(
"SpringBootMailHTML之这是一封HTML格式的邮件"
);
//抄送给谁
mailBean
.
setCc
(
new
String
[]{
"786775527@qq.com"
,
"286968900@qq.com"
});
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"<h2>SpringBoot测试邮件HTML</h2>"
)
.
append
(
"<p style='text-align:left'>这是一封HTML邮件...</p>"
)
.
append
(
"<p> 时间为:"
+
new
Date
()
+
"</p>"
);
mailBean
.
setContent
(
sb
.
toString
());
mailBean
.
setAttachFileNames
(
new
String
[]{
"/Users/Downloads/密码管理.xlsx"
,
"/Users/Downloads/1635834323888.jpg"
});
emailSendMsgHandle
.
sendEnclosureEmail
(
mailBean
);
}
@Test
void
sendEmail2
()
{
MailInfo
mailBean
=
new
MailInfo
();
mailBean
.
setReceiver
(
new
String
[]{
"qinyingjie@deepexi.com"
});
mailBean
.
setSubject
(
"SpringBootMailHTML之这是一封HTML格式的邮件"
);
mailBean
.
setCc
(
new
String
[]{
"786775527@qq.com"
,
"286968900@qq.com"
});
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"<h2>SpringBoot测试邮件HTML</h2>"
)
.
append
(
"<p style='text-align:left'>这是一封HTML邮件...</p>"
)
.
append
(
"<a href=http://www.baidu.com>点击进入百度</a><br/>"
)
//内嵌图片
.
append
(
"<img src=\"cid:a00000001\"><br/><br/>"
)
.
append
(
"<img src=\"cid:a00000002\">"
)
.
append
(
"<p> 时间为:"
+
new
Date
()
+
"</p>"
);
mailBean
.
setContent
(
sb
.
toString
());
//附件
mailBean
.
setAttachFileNames
(
new
String
[]{
"/Users/Downloads/密码管理.xlsx"
,
"/Users/Downloads/1635834323888.jpg"
});
//内嵌了多少张图片,如果没有,则new一个不带值的Map
Map
<
String
,
String
>
image
=
new
HashMap
<>();
image
.
put
(
"a00000001"
,
"/Users/Downloads/WechatIMG22.jpg"
);
image
.
put
(
"a00000002"
,
"/Users/Downloads/face_1631083961355.png"
);
mailBean
.
setImageMap
(
image
);
emailSendMsgHandle
.
sendEnclosureEmail
(
mailBean
);
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录