- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我写了一个程序来练习redis。但是当我作为JUnit测试运行时,出现了问题:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jedisClientPool' defined in class path resource [spring/applicationContext-redis.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'jedisPool' of bean class [cn.e3mall.common.jedis.JedisClientPool]: 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?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1518)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at cn.e3mall.jedis.JedisClientTest.testJedisClient(JedisClientTest.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'jedisPool' of bean class [cn.e3mall.common.jedis.JedisClientPool]: 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?
at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231)
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:423)
at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:280)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514)
... 36 more
这是我的 test:
这里是 applicationContext-redis.xml:
JedisClientPool.java:
package cn.e3mall.common.jedis;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class JedisClientPool implements JedisClient {
@Autowired
private JedisPool jedisPool;
@Override
public String set(String key, String value) {
Jedis jedis = jedisPool.getResource();
String result = jedis.set(key, value);
jedis.close();
return result;
}
@Override
public String get(String key) {
Jedis jedis = jedisPool.getResource();
String result = jedis.get(key);
jedis.close();
return result;
}
@Override
public Boolean exists(String key) {
Jedis jedis = jedisPool.getResource();
Boolean result = jedis.exists(key);
jedis.close();
return result;
}
@Override
public Long expire(String key, int seconds) {
Jedis jedis = jedisPool.getResource();
Long result = jedis.expire(key, seconds);
jedis.close();
return result;
}
@Override
public Long ttl(String key) {
Jedis jedis = jedisPool.getResource();
Long result = jedis.ttl(key);
jedis.close();
return result;
}
@Override
public Long incr(String key) {
Jedis jedis = jedisPool.getResource();
Long result = jedis.incr(key);
jedis.close();
return result;
}
@Override
public Long hset(String key, String field, String value) {
Jedis jedis = jedisPool.getResource();
Long result = jedis.hset(key, field, value);
jedis.close();
return result;
}
@Override
public String hget(String key, String field) {
Jedis jedis = jedisPool.getResource();
String result = jedis.hget(key, field);
jedis.close();
return result;
}
@Override
public Long hdel(String key, String... field) {
Jedis jedis = jedisPool.getResource();
Long result = jedis.hdel(key, field);
jedis.close();
return result;
}
@Override
public Boolean hexists(String key, String field) {
Jedis jedis = jedisPool.getResource();
Boolean result = jedis.hexists(key, field);
jedis.close();
return result;
}
@Override
public List<String> hvals(String key) {
Jedis jedis = jedisPool.getResource();
List<String> result = jedis.hvals(key);
jedis.close();
return result;
}
@Override
public Long del(String key) {
Jedis jedis = jedisPool.getResource();
Long result = jedis.del(key);
jedis.close();
return result;
}
}
JedisClient.java:
package cn.e3mall.common.jedis;
import java.util.List;
public interface JedisClient {
String set(String key, String value);
String get(String key);
Boolean exists(String key);
Long expire(String key, int seconds);
Long ttl(String key);
Long incr(String key);
Long hset(String key, String field, String value);
String hget(String key, String field);
Long hdel(String key, String... field);
Boolean hexists(String key,String field);
List<String> hvals(String key);
Long del(String key);
}
你能帮我吗?谢谢!!
最佳答案
我在 JedisClientPool
中没有看到 JedisClient
实例的 getter/setter。
一定要创建它们。
关于spring - org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'jedisClientPool' defined in class path resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44297802/
刚开始处理Maven和Spring。当我尝试创建DAO和ResultSet然后运行应用程序时,抛出errors: Error:(4, 31) java: package org.springframe
问题: Error:(15, 10) java: cannot find symbol symbol: class SpringRunner Error:(16, 2) java: cannot
我正在尝试构建这个 RESTful 服务示例:https://spring.io/guides/gs/rest-service/GreetingController.java 的导入没有错误: pac
如果我尝试向构造函数注入(inject) Facebook 参数,我将尝试使用 facebook api 使用 spring + thymeleaf + hibernate 创建 Facebook 应
如何解决Spring中Bean的自动连接歧义?我们有一个 Dessert 接口(interface),并且有实现该接口(interface)(Dessert)的三种不同的甜点(Bean)。 今天的甜点
请问为什么我的 pom.xml 文件中会出现此错误 Missing artifact org.springframework:spring-context:jar:${org.springframew
让 gradle 构建正常工作( from a previous question related to this one ),安迪·威尔金森(Andy Wilkinson)为我回答,没有问题。正在为
我正在 tomcat 7 中开发网站(spring 3.1.1),但出现错误 ERROR: org.springframework.web.context.ContextLoader - Contex
我在将航类信息保存到 mysql 数据库时遇到错误。请帮助我下面是我的代码: 我已经尝试了所有方法,添加模式和这么多 它不会从字符串转换为日期 控制台日志 2020-05-12 13:19:21.04
我使用intellij创建了一个小型java应用程序,后来我使用“添加框架支持”选项将该项目更新为Maven项目。当我厌倦了在项目上添加 spring jar 文件时,出现以下错误:“没有为 org.
我尝试使用 org.springframework.data.mongodb.core.MongoOperations 从 mongo 集合中查询记录。我在 CompanyTemplRepoImpl
我尝试将 Spring4 与 Hibernate5 一起使用,但出现此错误: org.springframework.orm.jpa.EntityManagerHolder cannot be cas
我是这个论坛的新手。我正在尝试使用 spring 3.2.6 和 tomcat 7.0 制作一个应用程序。我已将所有必需的 jar 添加到 WEB-INF/lib 文件夹中。 DispatcherSe
我在 maven 架构中使用 Spring 框架 4.0.1.RELEASE、OAuth Security 2.0.7.RELEASE,当我编译代码时,出现以下错误。 SEVERE: Exceptio
我正在使用以下指令开发 CRUD Web 应用程序: https://www.javaguides.net/2019/02/spring-boot-2-angular-7-crud-example-t
这个问题已经有答案了: what is the difference in org.springframework.web.servlet.ModelAndView vs org.springfram
我正在尝试将 hibernate 与 spring boot 一起使用。但我收到此错误:org.springframework.orm.jpa.EntityManagerHolder 无法转换为 or
我尝试创建简单的用户登录和注册页面。但我无法使用服务方法创建用户。我有创建新用户的服务。 @Service public class LocalUserDetailsService implement
我用 STS、Roo 和 GWT 创建了一个新项目,并尝试包含 Spring Security。 从那时起,我收到以下错误。有没有人知道出了什么问题?! org.springframework.bea
这些是我正在使用的版本和依赖项 我怀疑版本需要更改但更改为什么,我不确定 springCore : '5.3.3', springjdbc
我是一名优秀的程序员,十分优秀!