package com.example.boot3.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springfr服务器托管网amework.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
m服务器托管网ax-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);
}
}
127.0.0.1:6381> shutdown
not connected> quit
[root@localhost ~]# redis-cli -a abc123 -p 6382 -c --raw
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6382> shutdown
not connected> quit
[root@localhost ~]# redis-server /myredis/redis6379.conf
[root@localhost ~]# redis-cli -a abc123 -p 6379 --raw
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> get haha
12
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
加载镜像 docker 服务器托管网load 运行镜像 docker run -itd –name kkfileview –restart always -p 8012:8012 kekin服务器托管网g/kkfileview:latest 由于kkfil…