feat:redis集成
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -42,6 +42,11 @@
|
|||||||
<artifactId>xservice-schedule-starter</artifactId>
|
<artifactId>xservice-schedule-starter</artifactId>
|
||||||
<version>1.1-snapshot</version>
|
<version>1.1-snapshot</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.xiang</groupId>
|
||||||
|
<artifactId>xservice-cache</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.xiang.xservice;
|
package com.xiang.xservice;
|
||||||
|
|
||||||
import com.xiang.xservice.basic.common.resp.Result;
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -12,8 +14,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/demo")
|
@RequestMapping("/system/demo")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
|
|
||||||
|
private final RedisTemplate<String, String> redisTemplate;
|
||||||
|
|
||||||
@Value("${spring.profiles.active}")
|
@Value("${spring.profiles.active}")
|
||||||
private String env;
|
private String env;
|
||||||
|
|
||||||
@@ -28,4 +33,11 @@ public class IndexController {
|
|||||||
String msg = "已激活环境:" + env + ",web端口启用:" + port + "使用datasource:" + url;
|
String msg = "已激活环境:" + env + ",web端口启用:" + port + "使用datasource:" + url;
|
||||||
return Result.success(msg);
|
return Result.success(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/redisTest")
|
||||||
|
private Result<Void> redisTest() {
|
||||||
|
redisTemplate.opsForValue().set("2222", "231");
|
||||||
|
|
||||||
|
return Result.success("redis获取到key为test的值为:" + redisTemplate.opsForValue().get("2222"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user