当前位置:网站首页 > R语言数据分析 > 正文

yml文件配置redis(yaml配置redis)



 
   
package com.example.boot3.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @Autowired private StringRedisTemplate redisTemplate; @GetMapping("/hello") public String Hello(){ return "Hello"; } @GetMapping("/incr") public String incr(){ Long haha = redisTemplate.opsForValue().increment("haha"); return "增加后的为" + haha; } } 

 
   
 
  
    
     
  
    
     
   
     
     
       4.0.0 
      
   
     
      
      
        org.springframework.boot 
       
      
        spring-boot-starter-parent 
       
      
        3.2.1 
       
       
       
      
   
     
     
       com.example 
      
   
     
     
       boot3 
      
   
     
     
       0.0.1-SNAPSHOT 
      
   
     
     
       boot3 
      
   
     
     
       boot3 
      
   
     
      
      
        17 
       
      
   
     
      
       
       
         org.springframework.boot 
        
       
         spring-boot-starter-thymeleaf 
        
       
       
       
         org.springframework.boot 
        
       
         spring-boot-starter-web 
        
       
       
       
         com.alibaba 
        
       
         druid 
        
       
         1.2.16 
        
       
       
       
         org.springframework.boot 
        
       
         spring-boot-starter-data-redis 
        
       
       
       
         org.springframework.boot 
        
       
         spring-boot-starter-test 
        
       
         test 
        
       
      
   
     
      
       
        
        
          org.springframework.boot 
         
        
          spring-boot-maven-plugin 
         
        
       
      
  
    
     
 
   
server: port: 9999 spring: servlet: multipart: max-file-size: 10MB data: redis: host: 192.168.92.129 port: 6379 database: 0 password: abc123 lettuce: pool: max-active: 8 max-wait: -1ms max-idle: 8 min-idle: 0 timeout: 5000
 
   
 
  
    
     
  
    
     
   
     
      
       
       
      
   
     
      
       
       
      
  
    
    
 
   
package com.example.boot3; import com.example.boot3.bean.*; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; @ComponentScan("com.example")//改变包扫描路径 @SpringBootApplication(scanBasePackages = "com.example.boot3")//手动指定扫描包位置 public class Boot3Application { public static void main(String[] args) { var ioc = SpringApplication.run(Boot3Application.class, args); // for (String name : ioc.getBeanDefinitionNames()) { // System.out.println(name); // } // Object user = ioc.getBean("user"); // Object user1 = ioc.getBean("user"); // System.out.println(user == user1); // System.out.println(ioc.getBean("fastsqlException")); for (String s : ioc.getBeanNamesForType(Cat.class)) { System.out.println(s); } for (String s : ioc.getBeanNamesForType(Dog.class)) { System.out.println(s); } for (String s : ioc.getBeanNamesForType(User.class)) { System.out.println(s); } Object pig = ioc.getBean("pig"); System.out.println(pig); // for (String s : ioc.getBeanNamesForType(Sheep.class)) { // System.out.println(s); // } Object sheep = ioc.getBean(Sheep.class); System.out.println(sheep); } } 
 
  
到此这篇yml文件配置redis(yaml配置redis)的文章就 介绍到这了,更多相关内容请继续浏览下面的相关 推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • top18女rapper日本(日本十大rapper)2026-05-01 20:54:05
  • pdfviewer下载在线PDF文件(pdfviewer pro 下载)2026-05-01 20:54:05
  • uchar seg(uchar seg什么意思)2026-05-01 20:54:05
  • ortcc系统(orc技术)2026-05-01 20:54:05
  • druiddatasource卡住(druid datasource already closed)2026-05-01 20:54:05
  • redis连接需要关闭吗(redis连接超时该如何解决)2026-05-01 20:54:05
  • word文档多级列表怎么设置(word中如何设置多级列表)2026-05-01 20:54:05
  • ar是什么?(ar是什么软件)2026-05-01 20:54:05
  • vbf是什么类型的游戏(vbr是什么游戏)2026-05-01 20:54:05
  • torturing翻译(torture翻译)2026-05-01 20:54:05
  • 全屏图片