parent
9a611b8cf0
commit
e8ee0ff8c8
@ -0,0 +1,47 @@
|
||||
<?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>
|
||||
<parent>
|
||||
<groupId>com.mashibing</groupId>
|
||||
<artifactId>beacon-cloud</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>beacon-cache</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- nacos注册中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<!-- nacos配置中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<!-- openFeign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<!-- <!– redis –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.msb.cloud</groupId>
|
||||
<artifactId>horse-framework-starter-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,22 @@
|
||||
package com.mashibing.cache;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: CacheApplication
|
||||
* @Description: CacheApplication模块启动类
|
||||
* @date 2025/6/5 13:35
|
||||
*/
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
@EnableDiscoveryClient
|
||||
public class CacheApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CacheApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.mashibing.cache.controller;
|
||||
|
||||
import com.msb.framework.redis.RedisClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author heqijun
|
||||
* @ClassName: CacheController
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @date 2025/6/5 13:46
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("cache")
|
||||
public class CacheController {
|
||||
|
||||
@Autowired
|
||||
private RedisClient redisClient;
|
||||
|
||||
@GetMapping("getString/{key}")
|
||||
public String getString(@PathVariable String key) {
|
||||
return redisClient.get(key);
|
||||
}
|
||||
|
||||
@GetMapping("setString/{key}/{value}")
|
||||
public String setString(@PathVariable String key, @PathVariable String value) {
|
||||
redisClient.set(key, value);
|
||||
return "保存成功";
|
||||
}
|
||||
|
||||
@GetMapping("getHash/{key}")
|
||||
public Map getHash(@PathVariable String key) {
|
||||
return redisClient.hGetAll(key);
|
||||
}
|
||||
|
||||
@PostMapping("setHash/{key}")
|
||||
public String setHash(@PathVariable String key, @RequestBody Map hash) {
|
||||
redisClient
|
||||
return "保存成功";
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
# 服务名称
|
||||
spring:
|
||||
application:
|
||||
name: beacon-cache
|
||||
# 多环境
|
||||
profiles:
|
||||
active: dev
|
||||
# nacos注册中心地址
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.1.13:8848
|
||||
# nacos配置中心地址:
|
||||
config:
|
||||
server-addr: 192.168.1.13:8848
|
||||
file-extension: yml
|
||||
|
||||
# beacon-cache-dev.yml
|
Loading…
Reference in new issue