File tree Expand file tree Collapse file tree 7 files changed +29
-204
lines changed 
springboot-batch/src/main/java/com/xncoding/trans/modules/common 
java/com/xncoding/pos/service 
test/java/com/xncoding/service Expand file tree Collapse file tree 7 files changed +29
-204
lines changed   Load Diff This file was deleted. 
Original file line number Diff line number Diff line change 4747        <dependency >
4848            <groupId >org.springframework.boot</groupId >
4949            <artifactId >spring-boot-starter-test</artifactId >
50+             <scope >test</scope >
5051            <exclusions >
5152                <exclusion >
5253                    <groupId >com.vaadin.external.google</groupId >
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ spring:
1010  profiles :
1111    active : dev 
1212  datasource :
13-     url : jdbc:mysql://123.207.66.156 :3306/test?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 
13+     url : jdbc:mysql://127.0.0.1 :3306/test?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 
1414    username : root 
15-     password : _EnZhi123 
15+     password : 123456 
1616
1717# ##################  mybatis-plus配置  ###################
1818mybatis-plus :
@@ -48,7 +48,7 @@ spring:
4848      use-key-prefix : true 
4949    cache-names : userCache,allUsersCache 
5050  redis :
51-     host : 123.207.66.156 
51+     host : 127.0.0.1 
5252    port : 6379 
5353    database : 0 
5454    lettuce :
Original file line number Diff line number Diff line change 3434            <groupId >org.springframework.boot</groupId >
3535            <artifactId >spring-boot-starter-data-redis</artifactId >
3636        </dependency >
37+         <dependency >
38+             <groupId >org.apache.commons</groupId >
39+             <artifactId >commons-pool2</artifactId >
40+         </dependency >
3741
3842        <dependency >
3943            <groupId >com.fasterxml.jackson.core</groupId >
5458        <dependency >
5559            <groupId >org.springframework.boot</groupId >
5660            <artifactId >spring-boot-starter-test</artifactId >
61+             <scope >test</scope >
5762            <exclusions >
5863                <exclusion >
5964                    <groupId >com.vaadin.external.google</groupId >
Original file line number Diff line number Diff line change 77import  org .springframework .data .redis .core .RedisTemplate ;
88import  org .springframework .data .redis .core .ValueOperations ;
99import  org .springframework .stereotype .Service ;
10+ import  org .springframework .transaction .annotation .Transactional ;
1011
1112import  javax .annotation .Resource ;
1213import  java .util .concurrent .TimeUnit ;
1314
1415@ Service 
16+ @ Transactional 
1517public  class  UserService  {
1618    private  Logger  logger  = LoggerFactory .getLogger (this .getClass ());
1719    @ Resource 
Original file line number Diff line number Diff line change 77  profiles :
88    active : dev 
99  datasource :
10-     url : jdbc:mysql://127.0.0.1 :3306/test?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 
10+     url : jdbc:mysql://123.207.66.156 :3306/test?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 
1111    username : root 
12-     password : 123456 
12+     password : _EnZhi123 
1313
1414# ##################  mybatis-plus配置  ###################
1515mybatis-plus :
@@ -39,16 +39,22 @@ spring:
3939  profiles : dev 
4040  cache :
4141    type : REDIS 
42+     redis :
43+       cache-null-values : false 
44+       time-to-live : 600000ms 
45+       use-key-prefix : true 
46+     cache-names : userCache,allUsersCache 
4247  redis :
43-     host : 127.0.0.1 
48+     host : 123.207.66.156 
4449    port : 6379 
45-     timeout : 0 
4650    database : 0 
47-     pool :
48-       max-active : 100 
49-       max-wait : -1 
50-       max-idle : 8 
51-       min-idle : 0 
51+     lettuce :
52+       shutdown-timeout : 200ms 
53+       pool :
54+         max-active : 7 
55+         max-idle : 7 
56+         min-idle : 2 
57+         max-wait : -1ms 
5258
5359logging :
5460  level :
Original file line number Diff line number Diff line change 88import  org .springframework .beans .factory .annotation .Autowired ;
99import  org .springframework .boot .test .context .SpringBootTest ;
1010import  org .springframework .test .context .junit4 .SpringRunner ;
11+ import  org .springframework .transaction .annotation .Transactional ;
1112
1213import  java .util .Random ;
1314
2425 */ 
2526@ RunWith (SpringRunner .class )
2627@ SpringBootTest (classes  = Application .class )
28+ @ Transactional 
2729public  class  UserServiceTest  {
2830    @ Autowired 
2931    private  UserService  userService ;
3032    @ Test 
3133    public  void  testCache () {
32-         int  id  = new  Random ().nextInt (100 );
34+         int  id  = new  Random ().nextInt (1000 );
3335        User  user  = new  User (id , "admin" , "admin" );
3436        userService .createUser (user );
3537        User  user1  = userService .getById (id ); // 第1次访问 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments