彩云小梦如何控制 AI续写的情感细腻度与悲喜反差?
2026-07-31
2026-08-05 0
1.创建一个demo项目

4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.5.RELEASE com.example demo 0.0.1-SNAPSHOT demo Demo project for Spring Boot 1.8 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin 2.配置DemoApplication文件
@SpringBootApplication@EnableCachingpublic class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);}}3.编写DemoController
@RestControllerpublic class DemoController {@Autowiredprivate DemoService demoService;@GetMapping("demo")public boolean demo(@RequestParam("id") Integer id){return demoService.demo(id);}}4.编写DemoService
package com.example.demo;import org.springframework.cache.annotation.Cacheable;import org.springframework.stereotype.Service;@Servicepublic class DemoService {/** * 当id大于10时使用缓存 * 当id小于或等于10时不使用缓存 * @param id * @return */@Cacheable(value = "id",key = "#id",condition = "#id>10")public boolean demo(Integer id){System.out.println("---->未使用缓存");if(id==20){ return true;}else{return false;}}}5.配置服务端口
server.port=11116.测试
http://127.0.0.1:1111/demo?id=107.spring-boot使用tools-redis实现分布式缓存