File tree Expand file tree Collapse file tree 5 files changed +71
-2
lines changed Expand file tree Collapse file tree 5 files changed +71
-2
lines changed Original file line number Diff line number Diff line change 92
92
<artifactId >druid</artifactId >
93
93
<version >1.0.5</version >
94
94
</dependency >
95
+ <!-- ehcache的依赖-->
96
+ <dependency >
97
+ <groupId >net.sf.ehcache</groupId >
98
+ <artifactId >ehcache</artifactId >
99
+ </dependency >
100
+ <dependency >
101
+ <!-- java mail的依赖-->
102
+ <groupId >org.springframework.boot</groupId >
103
+ <artifactId >spring-boot-starter-mail</artifactId >
104
+ </dependency >
95
105
</dependencies >
96
106
97
107
<build >
Original file line number Diff line number Diff line change @@ -17,11 +17,21 @@ public class CacheController {
17
17
private CacheService cacheService ;
18
18
19
19
@ RequestMapping (value = "" ,method = RequestMethod .GET )
20
- public String getByCache (){
20
+ public String getByCache () {
21
21
long startTme = System .currentTimeMillis ();
22
22
long timeTme = this .cacheService .getByCache ();
23
23
long endTme = System .currentTimeMillis ();
24
24
System .out .println ("耗时:" + (endTme - startTme ));
25
25
return timeTme + "" ;
26
26
}
27
+
28
+ @ RequestMapping (value = "" ,method = RequestMethod .POST )
29
+ public void save (){
30
+ this .cacheService .save ();
31
+ }
32
+
33
+ @ RequestMapping (value = "" ,method = RequestMethod .DELETE )
34
+ public void delete (){
35
+ this .cacheService .delete ();
36
+ }
27
37
}
Original file line number Diff line number Diff line change @@ -63,4 +63,11 @@ spring:
63
63
host : localhost
64
64
port : 5672
65
65
username : guest
66
- password : guest
66
+ password : guest
67
+ mail :
68
+ host : smpt.163.com
69
+ username :
70
+ password :
71
+ port : 25
72
+ protocol : smtp
73
+ default-encoding : utf-8
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <ehcache xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi : noNamespaceSchemaLocation =" ehcache.xsd" >
4
+ <cache name =" ehcache"
5
+ maxElementsInMemory =" 1000"
6
+ timeToLiveSeconds =" 300" >
7
+ </cache >
8
+ </ehcache >
Original file line number Diff line number Diff line change
1
+ package com .example ;
2
+
3
+ import org .junit .Test ;
4
+ import org .junit .runner .RunWith ;
5
+ import org .springframework .beans .factory .annotation .Autowired ;
6
+ import org .springframework .boot .test .context .SpringBootTest ;
7
+ import org .springframework .mail .SimpleMailMessage ;
8
+ import org .springframework .mail .javamail .JavaMailSenderImpl ;
9
+ import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
10
+
11
+ /**
12
+ * Created by zhuzhengping on 2017/3/16.
13
+ */
14
+ @ RunWith (SpringJUnit4ClassRunner .class )
15
+ @ SpringBootTest
16
+ public class MailTest {
17
+
18
+
19
+ @ Autowired
20
+ private JavaMailSenderImpl mailSender ;
21
+
22
+ @ Test
23
+ public void send (){
24
+ SimpleMailMessage simpleMailMessage = new SimpleMailMessage ();
25
+ simpleMailMessage .setTo (new String []{"1111111111@qq.com" });
26
+ simpleMailMessage .setFrom ("zhu_zhengping@163.com" );
27
+ simpleMailMessage .setSubject ("spring boot mail [text]" );
28
+ simpleMailMessage .setText (" this is an simple text " );
29
+
30
+ mailSender .send (simpleMailMessage );
31
+
32
+ System .out .println ("mail has been send" );
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments