Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dc-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jianshuqin
dc-common
Commits
ad1b7dca
Commit
ad1b7dca
authored
Mar 06, 2020
by
yinyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mail
parent
1b0b0db8
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
416 additions
and
0 deletions
+416
-0
data-skywalking.iml
data-skywalking/data-skywalking.iml
+87
-0
pom.xml
data-skywalking/pom.xml
+54
-0
SkyWalkingApplication.java
...ng/src/main/java/com/bailuntec/SkyWalkingApplication.java
+13
-0
SkyWalkingNotice.java
.../main/java/com/bailuntec/controller/SkyWalkingNotice.java
+23
-0
SkyWalkingNoticeService.java
...n/java/com/bailuntec/service/SkyWalkingNoticeService.java
+12
-0
Test.java
...-skywalking/src/main/java/com/bailuntec/service/Test.java
+4
-0
SkyWalkingNoticeServiceImpl.java
...m/bailuntec/service/impl/SkyWalkingNoticeServiceImpl.java
+182
-0
application.yml
data-skywalking/src/main/resources/application.yml
+21
-0
AppTest.java
data-skywalking/src/test/java/com/bailuntec/AppTest.java
+20
-0
No files found.
data-skywalking/data-skywalking.iml
0 → 100644
View file @
ad1b7dca
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"FacetManager"
>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration
/>
</facet>
<facet
type=
"web"
name=
"Web"
>
<configuration>
<webroots
/>
<sourceRoots>
<root
url=
"file://$MODULE_DIR$/src/main/java"
/>
<root
url=
"file://$MODULE_DIR$/src/main/resources"
/>
</sourceRoots>
</configuration>
</facet>
</component>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
<output-test
url=
"file://$MODULE_DIR$/target/test-classes"
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/java"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/resources"
type=
"java-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/java"
isTestSource=
"true"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/target"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-web:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-autoconfigure:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-logging:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: ch.qos.logback:logback-classic:1.2.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: ch.qos.logback:logback-core:1.2.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.logging.log4j:log4j-to-slf4j:2.10.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.logging.log4j:log4j-api:2.10.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:jul-to-slf4j:1.7.25"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.annotation:javax.annotation-api:1.3.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"RUNTIME"
name=
"Maven: org.yaml:snakeyaml:1.19"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-json:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-databind:2.9.6"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-core:2.9.6"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.6"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.6"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.6"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-tomcat:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.34"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.34"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.34"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate.validator:hibernate-validator:6.0.12.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.validation:validation-api:2.0.1.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.jboss.logging:jboss-logging:3.3.2.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml:classmate:1.3.4"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-web:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-beans:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-webmvc:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-aop:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-context:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-expression:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-starter-test:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-test:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.0.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: com.jayway.jsonpath:json-path:2.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.minidev:json-smart:2.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.minidev:accessors-smart:1.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.ow2.asm:asm:5.0.4"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-api:1.7.25"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: junit:junit:4.12"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.assertj:assertj-core:3.9.1"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.mockito:mockito-core:2.15.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.bytebuddy:byte-buddy:1.7.11"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.bytebuddy:byte-buddy-agent:1.7.11"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.objenesis:objenesis:2.6"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.hamcrest:hamcrest-core:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.hamcrest:hamcrest-library:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.skyscreamer:jsonassert:1.5.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-core:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-jcl:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework:spring-test:5.0.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.xmlunit:xmlunit-core:2.5.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.mail:mail:1.4.5"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.activation:activation:1.1"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
data-skywalking/pom.xml
0 → 100644
View file @
ad1b7dca
<?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"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.bailuntec
</groupId>
<artifactId>
data-skywalking
</artifactId>
<version>
1.0.1
</version>
<packaging>
jar
</packaging>
<name>
data-skywalking
</name>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
</properties>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.0.5.RELEASE
</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
javax.mail
</groupId>
<artifactId>
mail
</artifactId>
<version>
1.4.5
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
data-skywalking/src/main/java/com/bailuntec/SkyWalkingApplication.java
0 → 100644
View file @
ad1b7dca
package
com
.
bailuntec
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
SkyWalkingApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SkyWalkingApplication
.
class
,
args
);
}
}
data-skywalking/src/main/java/com/bailuntec/controller/SkyWalkingNotice.java
0 → 100644
View file @
ad1b7dca
package
com
.
bailuntec
.
controller
;
import
com.bailuntec.service.SkyWalkingNoticeService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.mail.MessagingException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.security.GeneralSecurityException
;
@RestController
public
class
SkyWalkingNotice
{
@Autowired
private
SkyWalkingNoticeService
skyWalkingNoticeService
;
@GetMapping
(
value
=
"notice"
)
public
void
notice
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
GeneralSecurityException
,
MessagingException
{
skyWalkingNoticeService
.
send
(
"邮件主题"
,
"邮件内容"
);
}
}
data-skywalking/src/main/java/com/bailuntec/service/SkyWalkingNoticeService.java
0 → 100644
View file @
ad1b7dca
package
com
.
bailuntec
.
service
;
import
javax.mail.MessagingException
;
import
javax.mail.NoSuchProviderException
;
import
java.security.GeneralSecurityException
;
public
interface
SkyWalkingNoticeService
{
void
send
(
String
subject
,
String
content
)
throws
GeneralSecurityException
,
MessagingException
;
void
sendComplex
()
throws
GeneralSecurityException
,
MessagingException
;
}
data-skywalking/src/main/java/com/bailuntec/service/Test.java
0 → 100644
View file @
ad1b7dca
package
com
.
bailuntec
.
service
;
public
class
Test
{
}
data-skywalking/src/main/java/com/bailuntec/service/impl/SkyWalkingNoticeServiceImpl.java
0 → 100644
View file @
ad1b7dca
package
com
.
bailuntec
.
service
.
impl
;
import
com.bailuntec.service.SkyWalkingNoticeService
;
import
com.sun.mail.util.MailSSLSocketFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
javax.activation.DataHandler
;
import
javax.activation.FileDataSource
;
import
javax.mail.*
;
import
javax.mail.internet.InternetAddress
;
import
javax.mail.internet.MimeBodyPart
;
import
javax.mail.internet.MimeMessage
;
import
javax.mail.internet.MimeMultipart
;
import
java.security.GeneralSecurityException
;
import
java.util.Properties
;
@Service
public
class
SkyWalkingNoticeServiceImpl
implements
SkyWalkingNoticeService
{
@Value
(
"${mail.from}"
)
private
String
from
;
@Value
(
"${mail.recipient}"
)
private
String
recipient
;
@Value
(
"${mail.password}"
)
private
String
password
;
@Value
(
"${mail.host}"
)
private
String
host
;
@Value
(
"${mail.transport.protocol}"
)
private
String
protocol
;
@Override
public
void
send
(
String
subject
,
String
content
)
throws
GeneralSecurityException
,
MessagingException
{
//创建一个配置文件并保存
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"mail.host"
,
host
);
properties
.
setProperty
(
"mail.transport.protocol"
,
protocol
);
properties
.
setProperty
(
"mail.smtp.auth"
,
"true"
);
//QQ存在一个特性设置SSL加密
MailSSLSocketFactory
sf
=
new
MailSSLSocketFactory
();
sf
.
setTrustAllHosts
(
true
);
properties
.
put
(
"mail.smtp.ssl.enable"
,
"true"
);
properties
.
put
(
"mail.smtp.ssl.socketFactory"
,
sf
);
//创建一个session对象
Session
session
=
Session
.
getDefaultInstance
(
properties
,
new
Authenticator
()
{
@Override
protected
PasswordAuthentication
getPasswordAuthentication
()
{
return
new
PasswordAuthentication
(
from
,
password
);
}
});
//开启debug模式
session
.
setDebug
(
true
);
//获取连接对象
Transport
transport
=
session
.
getTransport
();
//连接服务器
transport
.
connect
(
host
,
from
,
password
);
//创建邮件对象
MimeMessage
mimeMessage
=
new
MimeMessage
(
session
);
//邮件发送人
mimeMessage
.
setFrom
(
new
InternetAddress
(
from
));
//邮件接收人
mimeMessage
.
setRecipient
(
Message
.
RecipientType
.
TO
,
new
InternetAddress
(
recipient
));
//邮件标题
mimeMessage
.
setSubject
(
subject
);
//邮件内容
mimeMessage
.
setContent
(
content
,
"text/html;charset=UTF-8"
);
//发送邮件
transport
.
sendMessage
(
mimeMessage
,
mimeMessage
.
getAllRecipients
());
//关闭连接
transport
.
close
();
}
@Override
public
void
sendComplex
()
throws
GeneralSecurityException
,
MessagingException
{
Properties
prop
=
new
Properties
();
prop
.
setProperty
(
"mail.host"
,
host
);
//// 设置QQ邮件服务器
prop
.
setProperty
(
"mail.transport.protocol"
,
protocol
);
// 邮件发送协议
prop
.
setProperty
(
"mail.smtp.auth"
,
"true"
);
// 需要验证用户名密码
// QQ邮箱设置SSL加密
MailSSLSocketFactory
sf
=
new
MailSSLSocketFactory
();
sf
.
setTrustAllHosts
(
true
);
prop
.
put
(
"mail.smtp.ssl.enable"
,
"true"
);
prop
.
put
(
"mail.smtp.ssl.socketFactory"
,
sf
);
//1、创建定义整个应用程序所需的环境信息的 Session 对象
Session
session
=
Session
.
getDefaultInstance
(
prop
,
new
Authenticator
()
{
@Override
protected
PasswordAuthentication
getPasswordAuthentication
()
{
//传入发件人的姓名和授权码
return
new
PasswordAuthentication
(
from
,
password
);
}
});
//2、通过session获取transport对象
Transport
transport
=
session
.
getTransport
();
//3、通过transport对象邮箱用户名和授权码连接邮箱服务器
transport
.
connect
(
host
,
from
,
password
);
//4、创建邮件,传入session对象
MimeMessage
mimeMessage
=
complexEmail
(
session
);
//5、发送邮件
transport
.
sendMessage
(
mimeMessage
,
mimeMessage
.
getAllRecipients
());
//6、关闭连接
transport
.
close
();
}
public
MimeMessage
complexEmail
(
Session
session
)
throws
MessagingException
{
//消息的固定信息
MimeMessage
mimeMessage
=
new
MimeMessage
(
session
);
//发件人
mimeMessage
.
setFrom
(
new
InternetAddress
(
from
));
//收件人
mimeMessage
.
setRecipient
(
Message
.
RecipientType
.
TO
,
new
InternetAddress
(
recipient
));
//邮件标题
mimeMessage
.
setSubject
(
"带图片和附件的邮件"
);
//邮件内容
//准备图片数据
MimeBodyPart
image
=
new
MimeBodyPart
();
DataHandler
handler
=
new
DataHandler
(
new
FileDataSource
(
"E:\\IdeaProjects\\WebEmail\\resources\\测试图片.png"
));
image
.
setDataHandler
(
handler
);
image
.
setContentID
(
"test.png"
);
//设置图片id
//准备文本
MimeBodyPart
text
=
new
MimeBodyPart
();
text
.
setContent
(
"这是一段文本<img src='cid:test.png'>"
,
"text/html;charset=utf-8"
);
//附件
MimeBodyPart
appendix
=
new
MimeBodyPart
();
appendix
.
setDataHandler
(
new
DataHandler
(
new
FileDataSource
(
"E:\\IdeaProjects\\WebEmail\\resources\\测试文件.txt"
)));
appendix
.
setFileName
(
"test.txt"
);
//拼装邮件正文
MimeMultipart
mimeMultipart
=
new
MimeMultipart
();
mimeMultipart
.
addBodyPart
(
image
);
mimeMultipart
.
addBodyPart
(
text
);
mimeMultipart
.
setSubType
(
"related"
);
//文本和图片内嵌成功
//将拼装好的正文内容设置为主体
MimeBodyPart
contentText
=
new
MimeBodyPart
();
contentText
.
setContent
(
mimeMultipart
);
//拼接附件
MimeMultipart
allFile
=
new
MimeMultipart
();
allFile
.
addBodyPart
(
appendix
);
//附件
allFile
.
addBodyPart
(
contentText
);
//正文
allFile
.
setSubType
(
"mixed"
);
//正文和附件都存在邮件中,所有类型设置为mixed
//放到Message消息中
mimeMessage
.
setContent
(
allFile
);
mimeMessage
.
saveChanges
();
//保存修改
return
mimeMessage
;
}
}
data-skywalking/src/main/resources/application.yml
0 → 100644
View file @
ad1b7dca
server
:
port
:
80
servlet
:
context-path
:
/skywalking
mail
:
username
:
"
826972995@qq.com"
password
:
"
vyexuikneiyfbaje"
from
:
"
826972995@qq.com"
recipient
:
"
1171744158@qq.com"
host
:
"
smtp.qq.com"
transport
:
protocol
:
smtp
smtp
:
auth
:
true
ssl
:
enable
:
true
logging
:
file
:
log/skywalking.log
\ No newline at end of file
data-skywalking/src/test/java/com/bailuntec/AppTest.java
0 → 100644
View file @
ad1b7dca
package
com
.
bailuntec
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.junit.Test
;
/**
* Unit test for simple App.
*/
public
class
AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public
void
shouldAnswerWithTrue
()
{
assertTrue
(
true
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment