日志具体报错如下,无法启动应用
D:Javajdk1.8.0_77injava.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:D:SoftWareIntelliJ IDEA 2020.3.3libidea_rt.jar=49817:D:SoftWareIntelliJ IDEA 2020.3.3in" -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath D:Javajdk1.8.0_77jrelibcharsets.jar;D:Javajdk1.8.0_77jrelibdeploy.jar;D:Javajdk1.8.0_77jrelibextaccess-bridge-64.jar;D:Javajdk1.8.0_77jrelibextcldrdata.jar;D:Javajdk1.8.0_77jrelibextdnsns.jar;D:Javajdk1.8.0_77jrelibextjaccess.jar;D:Javajdk1.8.0_77jrelibextjfxrt.jar;D:Javajdk1.8.0_77jrelibextlocaledata.jar;D:Javajdk1.8.0_77jrelibext ashorn.jar;D:Javajdk1.8.0_77jrelibextsunec.jar;D:Javajdk1.8.0_77jrelibextsunjce_provider.jar;D:Javajdk1.8.0_77jrelibextsunmscapi.jar;D:Javajdk1.8.0_77jrelibextsunpkcs11.jar;D:Javajdk1.8.0_77jrelibextzipfs.jar;D:Javajdk1.8.0_77jrelibjavaws.jar;D:Javajdk1.8.0_77jrelibjce.jar;D:Javajdk1.8.0_77jrelibjfr.jar;D:Javajdk1.8.0_77jrelibjfxswt.jar;D:Javajdk1.8.0_77jrelibjsse.jar;D:Javajdk1.8.0_77jrelibmanagement-agent.jar;D:Javajdk1.8.0_77jrelibplugin.jar;D:Javajdk1.8.0_77jrelib esources.jar;D:Javajdk1.8.0_77jrelib t.jar;D:IDEA_projectdemo_redis argetclasses;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkootspring-boot-starter-data-redis2.7.6spring-boot-starter-data-redis-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkootspring-boot-starter2.7.6spring-boot-starter-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkootspring-boot2.7.6spring-boot-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkootspring-boot-autoconfigure2.7.6spring-boot-autoconfigure-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkootspring-boot-starter-logging2.7.6spring-boot-starter-logging-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositorychqoslogbacklogback-classic1.2.11logback-classic-1.2.11.jar;D:SoftWareapache-maven-3.6.0 epositorychqoslogbacklogback-core1.2.11logback-core-1.2.11.jar;D:SoftWareapache-maven-3.6.0 epositoryorgapachelogginglog4jlog4j-to-slf4j2.17.2log4j-to-slf4j-2.17.2.jar;D:SoftWareapache-maven-3.6.0 epositoryorgapachelogginglog4jlog4j-api2.17.2log4j-api-2.17.2.jar;D:SoftWareapache-maven-3.6.0 epositoryorgslf4jjul-to-slf4j1.7.36jul-to-slf4j-1.7.36.jar;D:SoftWareapache-maven-3.6.0 epositoryjakartaannotationjakarta.annotation-api1.3.5jakarta.annotation-api-1.3.5.jar;D:SoftWareapache-maven-3.6.0 epositoryorgyamlsnakeyaml1.30snakeyaml-1.30.jar;D:SoftWareapache-maven-3.6.0 epositoryiolettucelettuce-core6.1.10.RELEASElettuce-core-6.1.10.RELEASE.jar;D:SoftWareapache-maven-3.6.0 epositoryio etty etty-common4.1.85.Final etty-common-4.1.85.Final.jar;D:SoftWareapache-maven-3.6.0 epositoryio etty etty-handler4.1.85.Final etty-handler-4.1.85.Final.jar;D:SoftWareapache-maven-3.6.0 epositoryio etty etty-resolver4.1.85.Final etty-resolver-4.1.85.Final.jar;D:SoftWareapache-maven-3.6.0 epositoryio etty etty-buffer4.1.85.Final etty-buffer-4.1.85.Final.jar;D:SoftWareapache-maven-3.6.0 epositoryio etty etty-transport-native-unix-common4.1.85.Final etty-transport-native-unix-common-4.1.85.Final.jar;D:SoftWareapache-maven-3.6.0 epositoryio etty etty-codec4.1.85.Final etty-codec-4.1.85.Final.jar;D:SoftWareapache-maven-3.6.0 epositoryio etty etty-transport4.1.85.Final etty-transport-4.1.85.Final.jar;D:SoftWareapache-maven-3.6.0 epositoryioprojectreactor eactor-core3.4.25 eactor-core-3.4.25.jar;D:SoftWareapache-maven-3.6.0 epositoryorg eactivestreams eactive-streams1.0.4 eactive-streams-1.0.4.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkootspring-boot-starter-web2.7.6spring-boot-starter-web-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkootspring-boot-starter-json2.7.6spring-boot-starter-json-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositorycomfasterxmljacksoncorejackson-databind2.13.4.2jackson-databind-2.13.4.2.jar;D:SoftWareapache-maven-3.6.0 epositorycomfasterxmljacksoncorejackson-annotations2.13.4jackson-annotations-2.13.4.jar;D:SoftWareapache-maven-3.6.0 epositorycomfasterxmljacksoncorejackson-core2.13.4jackson-core-2.13.4.jar;D:SoftWareapache-maven-3.6.0 epositorycomfasterxmljacksondatatypejackson-datatype-jdk82.13.4jackson-datatype-jdk8-2.13.4.jar;D:SoftWareapache-maven-3.6.0 epositorycomfasterxmljacksondatatypejackson-datatype-jsr3102.13.4jackson-datatype-jsr310-2.13.4.jar;D:SoftWareapache-maven-3.6.0 epositorycomfasterxmljacksonmodulejackson-module-parameter-names2.13.4jackson-module-parameter-names-2.13.4.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkootspring-boot-starter-tomcat2.7.6spring-boot-starter-tomcat-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositoryorgapache omcatembed omcat-embed-core9.0.69 omcat-embed-core-9.0.69.jar;D:SoftWareapache-maven-3.6.0 epositoryorgapache omcatembed omcat-embed-el9.0.69 omcat-embed-el-9.0.69.jar;D:SoftWareapache-maven-3.6.0 epositoryorgapache omcatembed omcat-embed-websocket9.0.69 omcat-embed-websocket-9.0.69.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-web5.3.24spring-web-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-beans5.3.24spring-beans-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-webmvc5.3.24spring-webmvc-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-context5.3.24spring-context-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-expression5.3.24spring-expression-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkdataspring-data-redis1.7.2.RELEASEspring-data-redis-1.7.2.RELEASE.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkdataspring-data-keyvalue2.7.6spring-data-keyvalue-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkdataspring-data-commons2.7.6spring-data-commons-2.7.6.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-tx5.3.24spring-tx-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-oxm5.3.24spring-oxm-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-aop5.3.24spring-aop-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-context-support5.3.24spring-context-support-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgslf4jslf4j-api1.7.36slf4j-api-1.7.36.jar;D:SoftWareapache-maven-3.6.0 epositoryorgslf4jjcl-over-slf4j1.7.36jcl-over-slf4j-1.7.36.jar;D:SoftWareapache-maven-3.6.0 epository edisclientsjedis2.9.0jedis-2.9.0.jar;D:SoftWareapache-maven-3.6.0 epositoryorgapachecommonscommons-pool22.11.1commons-pool2-2.11.1.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-core5.3.24spring-core-5.3.24.jar;D:SoftWareapache-maven-3.6.0 epositoryorgspringframeworkspring-jcl5.3.24spring-jcl-5.3.24.jar com.example.demo.DemoApplication . ____ _ __ _ _ /\ / ___'_ __ _ _(_)_ __ __ _ ( ( )\___ | '_ | '_| | '_ / _` | \/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.7.6) 2024-01-22 09:53:27.701 INFO 7912 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication using Java 1.8.0_77 on LAPTOP-MBCTH7PD with PID 7912 (D:IDEA_projectdemo_redis argetclasses started by huayu in D:IDEA_projectdemo_redis) 2024-01-22 09:53:27.706 INFO 7912 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to 1 default profile: "default" 2024-01-22 09:53:28.422 ERROR 7912 --- [ main] o.s.boot.SpringApplication : Application run failed java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration.redisConnectionFactory at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-2.7.6.jar:2.7.6] at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:193) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:153) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:343) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) [spring-boot-2.7.6.jar:2.7.6] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na] Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485) ~[spring-core-5.3.24.jar:5.3.24] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:361) ~[spring-core-5.3.24.jar:5.3.24] at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:418) ~[spring-core-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:765) ~[spring-beans-5.3.24.jar:5.3.24] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_77] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:764) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:703) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:674) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1684) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:570) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:542) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:250) ~[spring-boot-autoconfigure-2.7.6.jar:2.7.6] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:243) ~[spring-boot-autoconfigure-2.7.6.jar:2.7.6] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:233) ~[spring-boot-autoconfigure-2.7.6.jar:2.7.6] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:181) ~[spring-boot-autoconfigure-2.7.6.jar:2.7.6] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:156) ~[spring-boot-autoconfigure-2.7.6.jar:2.7.6] at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.7.6.jar:2.7.6] ... 17 common frames omitted Caused by: java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/lettuce/LettuceClientConfiguration$LettuceClientConfigurationBuilder at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_77] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_77] at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_77] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467) ~[spring-core-5.3.24.jar:5.3.24] ... 33 common frames omitted Caused by: java.lang.ClassNotFoundException: org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration$LettuceClientConfigurationBuilder at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_77] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_77] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_77] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_77] ... 37 common frames omitted 2024-01-22 09:53:28.427 WARN 7912 --- [ main] o.s.boot.SpringApplication : Unable to close ApplicationContext java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485) ~[spring-core-5.3.24.jar:5.3.24] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:361) ~[spring-core-5.3.24.jar:5.3.24] at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:418) ~[spring-core-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:765) ~[spring-beans-5.3.24.jar:5.3.24] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_77] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:764) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:703) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:674) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1684) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:570) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:542) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:669) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:661) ~[spring-beans-5.3.24.jar:5.3.24] at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1300) ~[spring-context-5.3.24.jar:5.3.24] at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:864) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:852) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:839) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:779) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:317) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) [spring-boot-2.7.6.jar:2.7.6] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) [spring-boot-2.7.6.jar:2.7.6] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na] Caused by: java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/lettuce/LettuceClientConfiguration$LettuceClientConfigurationBuilder at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_77] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_77] at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_77] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467) ~[spring-core-5.3.24.jar:5.3.24] ... 21 common frames omitted Caused by: java.lang.ClassNotFoundException: org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration$LettuceClientConfigurationBuilder at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_77] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_77] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_77] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_77] ... 25 common frames omitted Process finished with exit code 1
pom.xml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd" > <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.7.6</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.7.2.RELEASE</version> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <image> <builder>paketobuildpacks/builder-jammy-base:latest</builder> </image> </configuration> </plugin> </plugins> </build> </project>
java程序
package com.example.demo.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 TestRedis { @Autowired public StringRedisTemplate redisTemplate; @GetMapping("count") public String count(){ long count = redisTemplate.opsForValue().increment("count",1); return "有【"+count+"】人访问了页面"; } }
出现这种问题的原因是版本不合适,使用springboot版本2.7.6,但是使用spring-boot-date的版本是1.7.2.RELEASE
注释版本
重新启动java程序,启动成功