forked from zhoustone/middle-ware-parent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SpringBoot2.0 整合 JavaMail ,实现异步发送邮件功能
- Loading branch information
cicadasmile
committed
Jun 11, 2019
0 parents
commit 518c105
Showing
16 changed files
with
748 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## 参考文章 | ||
|
||
<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483713&idx=1&sn=cd4228e19d07e0371af7ef06515f4298&chksm=fdf455f9ca83dcef81c44f10bff15a3d3a29553746eef9cad9d4e2a13c5d5709d95a375bff0a&token=949711998&lang=zh_CN#rd"> | ||
1、SpringBoot2.0 整合 shard-jdbc 中间件,实现数据分库分表</a><br/> | ||
|
||
<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483740&idx=1&sn=807e5372f14daa59220adecd0f0dc56d&chksm=fdf455e4ca83dcf2632bcf9144a6553e7e16f0ba46a9b59cb21085da05663467d90ad885528c&token=261735462&lang=zh_CN#rd"> | ||
2、SpringBoot2.0 整合 JavaMail ,实现异步发送邮件功能</a><br/> | ||
|
||
<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483755&idx=1&sn=9d78e7714ad4621fe5e643593069b186&chksm=fdf455d3ca83dcc5cdfa29de2dab4fee7595fc80a6d73f72cc782591e87c3ac296977daa6bc8&token=261735462&lang=zh_CN#rd"> | ||
3、SpringBoot2.0 整合 RocketMQ ,实现请求异步处理</a><br/> | ||
|
||
<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483767&idx=1&sn=fc845a2fb0ee7768946f8739101ac2aa&chksm=fdf455cfca83dcd9de4bac70f6cfa9a88907cdbb4ec7b0c2da13e65efc1a2564eb6599d38bc8&token=261735462&lang=zh_CN#rd"> | ||
4、SpringBoot2.0 整合 Swagger2 ,构建接口管理界面</a><br/> | ||
|
||
<a href="https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247483774&idx=1&sn=e5c2eed4a989bedd5c3b108c7dc18c37&chksm=fdf455c6ca83dcd0bccf71aa07639b8ef514e3b6e6d85c6aeb4bceae30d58f021c9d7ba8590b&token=261735462&lang=zh_CN#rd"> | ||
5、SpringBoot2.0 整合 QuartJob ,实现定时器实时管理</a><br/> | ||
|
||
## 项目简介 | ||
SpringBoot 集成常用中间件 | ||
|
||
SpringBoot集成常用开发中间件,分库分表,缓存,消息队列,定时器,权限管理等组件 | ||
|
||
# 我的公众号 | ||
关注公众号:知了一笑<br/> | ||
<img src="https://avatars0.githubusercontent.com/u/50793885?s=460&v=4"/> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starters</artifactId> | ||
<version>2.1.3.RELEASE</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.boot.parent</groupId> | ||
<artifactId>middle-ware-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<!-- 子模块管理 --> | ||
<modules> | ||
<!-- QuartJob 定时器 --> | ||
<module>ware-quart-job</module> | ||
<!-- RocketMq 消息中间件 --> | ||
<module>ware-rocket-queue</module> | ||
<!-- ShardJdbc 分库分表--> | ||
<module>ware-shard-jdbc</module> | ||
<!-- Redis 缓存 --> | ||
<!--<module>ware-redis-data</module>--> | ||
<!-- 整合右键发送 --> | ||
<module>ware-email-send</module> | ||
<!-- Swagger2 接口界面 --> | ||
<module>ware-swagger-two</module> | ||
</modules> | ||
|
||
<!-- 依赖版本管理 --> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
<spring-boot.version>2.1.3.RELEASE</spring-boot.version> | ||
<spring.version>5.1.5.RELEASE</spring.version> | ||
<mybatisplus.version>3.0.7.1</mybatisplus.version> | ||
<mysql.version>5.1.38</mysql.version> | ||
<mssql.version>4.0</mssql.version> | ||
<druid.version>1.1.13</druid.version> | ||
<quartz.version>2.3.0</quartz.version> | ||
<commons.lang.version>2.6</commons.lang.version> | ||
<commons.fileupload.version>1.2.2</commons.fileupload.version> | ||
<commons.io.version>2.5</commons.io.version> | ||
<commons.codec.version>1.10</commons.codec.version> | ||
<commons.configuration.version>1.10</commons.configuration.version> | ||
<swagger.version>2.6.1</swagger.version> | ||
<joda.time.version>2.9.9</joda.time.version> | ||
<fastjson.version>1.2.47</fastjson.version> | ||
<hutool.version>4.1.1</hutool.version> | ||
<lombok.version>1.18.4</lombok.version> | ||
<pagehelper.version>1.2.5</pagehelper.version> | ||
<common-util.version>1.0.3</common-util.version> | ||
<commons-lang3.version>3.8.1</commons-lang3.version> | ||
<rocketmq.version>4.3.0</rocketmq.version> | ||
<shard-jdbc.version>3.1.0</shard-jdbc.version> | ||
<redis-client.version>2.9.1</redis-client.version> | ||
<mail.version>1.5.0-b01</mail.version> | ||
</properties> | ||
|
||
<!-- 依赖管理 --> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-redis</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-aop</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-configuration-processor</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.baomidou</groupId> | ||
<artifactId>mybatis-plus-boot-starter</artifactId> | ||
<version>${mybatisplus.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.baomidou</groupId> | ||
<artifactId>mybatis-plus-generator</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.baomidou</groupId> | ||
<artifactId>mybatis-plus</artifactId> | ||
<version>${mybatisplus.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.pagehelper</groupId> | ||
<artifactId>pagehelper-spring-boot-starter</artifactId> | ||
<version>${pagehelper.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>${mysql.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>druid-spring-boot-starter</artifactId> | ||
<version>${druid.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.quartz-scheduler</groupId> | ||
<artifactId>quartz</artifactId> | ||
<version>${quartz.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.mchange</groupId> | ||
<artifactId>c3p0</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-lang</groupId> | ||
<artifactId>commons-lang</artifactId> | ||
<version>${commons.lang.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-fileupload</groupId> | ||
<artifactId>commons-fileupload</artifactId> | ||
<version>${commons.fileupload.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>${commons.io.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>${commons.codec.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-configuration</groupId> | ||
<artifactId>commons-configuration</artifactId> | ||
<version>${commons.configuration.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.springfox</groupId> | ||
<artifactId>springfox-swagger2</artifactId> | ||
<version>${swagger.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.springfox</groupId> | ||
<artifactId>springfox-swagger-ui</artifactId> | ||
<version>${swagger.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>${joda.time.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>fastjson</artifactId> | ||
<version>${fastjson.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>cn.hutool</groupId> | ||
<artifactId>hutool-all</artifactId> | ||
<version>${hutool.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>${lombok.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>tool</groupId> | ||
<artifactId>common-util</artifactId> | ||
<version>${common-util.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>${commons-lang3.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<!-- 插件管理 --> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>middle-ware-parent</artifactId> | ||
<groupId>com.boot.parent</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.email.send</groupId> | ||
<artifactId>ware-email-send</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<version>${spring-boot.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<version>${spring-boot.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-aop</artifactId> | ||
<version>${spring-boot.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-configuration-processor</artifactId> | ||
<version>${spring-boot.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>${joda.time.version}</version> | ||
</dependency> | ||
<!--邮件--> | ||
<dependency> | ||
<groupId>javax.mail</groupId> | ||
<artifactId>mail</artifactId> | ||
<version>${mail.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
13 changes: 13 additions & 0 deletions
13
ware-email-send/src/main/java/com/email/send/EmailApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.email.send; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
|
||
@EnableAsync | ||
@SpringBootApplication | ||
public class EmailApplication { | ||
public static void main(String[] args) { | ||
SpringApplication.run(EmailApplication.class,args) ; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
ware-email-send/src/main/java/com/email/send/controller/EmailController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.email.send.controller; | ||
|
||
import com.email.send.model.SendEmailModel; | ||
import com.email.send.param.EmailType; | ||
import com.email.send.service.EmailService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import javax.annotation.Resource; | ||
|
||
@RestController | ||
public class EmailController { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(EmailController.class) ; | ||
|
||
@Resource | ||
private EmailService emailService ; | ||
|
||
@RequestMapping("/sendEmail") | ||
public String sendEmail (){ | ||
SendEmailModel model = new SendEmailModel() ; | ||
model.setReceiver("[email protected]"); | ||
emailService.sendEmail(EmailType.EMAIL_TEXT_KEY.getCode(),model); | ||
LOGGER.info("执行结束====>>"); | ||
return "success" ; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
ware-email-send/src/main/java/com/email/send/model/SendEmailModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.email.send.model; | ||
|
||
/** | ||
* 邮件发送参数封装 | ||
*/ | ||
public class SendEmailModel { | ||
|
||
public static final String EMAIL_TEXT_KEY = "email_balance_key" ; | ||
public static final String EMAIL_IMAGE_KEY = "email_req_num_key" ; | ||
public static final String EMAIL_FILE_KEY = "email_open_account_key" ; | ||
|
||
/** | ||
* 收件人邮箱 | ||
*/ | ||
private String receiver ; | ||
|
||
|
||
public String getReceiver() { | ||
return receiver; | ||
} | ||
|
||
public void setReceiver(String receiver) { | ||
this.receiver = receiver; | ||
} | ||
|
||
} |
Oops, something went wrong.