java.lang.IllegalStateException: Failed to load ApplicationContext

来源:11-5 引入缓存技术之编码实现上

闻溪

2022-12-05

老师好,我用的IDEA,测试的时候报这个错误👇
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘shopListController’: Unsatisfied dependency expressed through field ‘areaService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘areaServiceImpl’: Unsatisfied dependency expressed through field ‘jedisKeys’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jedisKeys’ defined in class path resource [spring/spring-redis.xml]: Cannot resolve reference to bean ‘jedisUtil’ while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jedisUtil’ defined in class path resource [spring/spring-redis.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘jedisPool’ of bean class [com.jun.shopping.cache.JedisUtil]: Bean property ‘jedisPool’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

我的spring-redis.xml是这样配置的





<!-- 创建Redis工具类,封装好Redis的连接以进行相关的操作 -->
<bean id="jedisUtil" class="com.jun.shopping.cache.JedisUtil"
      scope="singleton">
    <property name="jedisPool" ref="jedisWritePool"/>
</bean>
<!-- Redis的key操作 -->
<bean id="jedisKeys" class="com.jun.shopping.cache.JedisUtil$Keys"
      scope="singleton">
</bean>
<!-- Redis的Strings操作 -->
<bean id="jedisStrings" class="com.jun.shopping.cache.JedisUtil$Strings"
      scope="singleton">

希望老师可以帮忙指点一下,这是哪里出错了,谢谢~

写回答

1回答

闻溪

提问者

2022-12-05

已解决,这么写就能用,但也不是很懂为啥

//img.mukewang.com/szimg/638db2620871f64d06220212.jpg

//img.mukewang.com/szimg/638db262085eaa2e06620267.jpg

//img.mukewang.com/szimg/638db263087d998b08700192.jpg


0
1
翔仔
同学好,这个容器启动起来后,会自动调用这个set方法注入对应的实例。
2022-12-06
共1条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程