spring、redis整合,实例化ConnectionFactory出错 10C

下面是我配置connectionFactory的代码

 @Bean
    public JedisConnectionFactory connectionFactory() throws IOException{
        Properties p = new Properties();
        // 加载redis配置文件
        p.load(CreateBeans.class.getResourceAsStream("/redis.properties"));
        // 配置JedisPool
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxIdle(Integer.parseInt(p.getProperty("redis.maxIdle")));
        poolConfig.setMaxTotal(Integer.parseInt(p.getProperty("redis.maxTotal")));
        poolConfig.setMaxWaitMillis(Integer.parseInt(p.getProperty("redis.maxWaitMillis")));
        poolConfig.setTestOnBorrow(Boolean.parseBoolean(p.getProperty("redis.testOnBorrow")));

        // 配置连接信息
        RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration();
        standaloneConfig.setHostName(p.getProperty("redis.host"));
        standaloneConfig.setPort(Integer.parseInt(p.getProperty("redis.port")));
        String pass = p.getProperty("redis.pass");
        if(pass != null && !pass.equals(""))
            standaloneConfig.setPassword(RedisPassword.of(pass));
        else
            standaloneConfig.setPassword(RedisPassword.none());

        DefaultJedisClientConfigurationBuilder builder = (DefaultJedisClientConfigurationBuilder) JedisClientConfiguration.builder();
        builder.usePooling();
        builder.poolConfig(poolConfig);
        builder.connectTimeout(Duration.ofMillis(Integer.parseInt(p.getProperty("redis.connTimeout"))));
        builder.readTimeout(Duration.ofMillis(Integer.parseInt(p.getProperty("redis.readTimeout"))));
        JedisClientConfiguration clientConfig = builder.build();

        return new JedisConnectionFactory(standaloneConfig, clientConfig);
    }

所引用的包
所引用的包
以上为引用的包,当然有些是配置redis不需要的。
下面是错误信息,

Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.data.redis.connection.jedis.JedisConnectionFactory
    at com.dimbbs.beans.CreateBeans.connectionFactory(CreateBeans.java:43)
    at com.dimbbs.beans.CreateBeans$$EnhancerBySpringCGLIB$$6ae8678c.CGLIB$connectionFactory$0(<generated>)
    at com.dimbbs.beans.CreateBeans$$EnhancerBySpringCGLIB$$6ae8678c$$FastClassBySpringCGLIB$$d2c7309d.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
    at com.dimbbs.beans.CreateBeans$$EnhancerBySpringCGLIB$$6ae8678c.connectionFactory(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 48 more

是不是我缺少什么包?

5个回答

缺少jar包吧,看看这个类需要的包

jedis客户端版本过高,

将jedis的版本号换低版本就好了

zqs164
zqs164 谢谢回复,是我少导了包
一年多之前 回复

spring-data-redis 目前只支持到 3.x, 4.x 不支持, 如果使用spring-data-redis, 把redis降到3.x试试

zqs164
zqs164 谢谢回复,是我少导了包,将版本我这里没成功
一年多之前 回复

我少导入了commons-beanutils-core-1.8.3.jar、spring-data-commons-2.0.8.RELEASE.jar和spring-data-keyvalue-2.0.8.RELEASE.jar三个包,导入了就ok了

和版本有关,查看一下jar的版本是否匹配

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
ConnectionFactory实例化问题
代码中运行到这句时rnConnectionFactory factory = ConnectionFactory.newInstance();rn出现异常:rnUnable to create ConnectionFactory: Provider com.sun.xml.registry.common.ConnectionFactoryImpl not foundrnrn怎么回事啊?
Spring和Redis整合详解
Spring和Redis整合详解 官方主页 Spring Spring Redis 概述 Redis是一个开源(BSD许可)的内存数据结构存储,用作数据库,缓存和消息代理。 简单来说,它是一个以(key,value)的形式存储数据的数据库. 官网:https://redis.io/download 去下载对应的版本。 Spring已经为我们对Redis做了很好的封装,我们需要做的就是配置和Serc...
Spring和redis的整合测试
1.项目导入spring_test和junit包.(使用maven直接在pom文件中添加) junit junit ${junit.version} test org.springframework spring-tes
spring和redis的整合
分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 超越昨天的自己系列(
Spring简单整合redis
项目环境:maven+sping4.2.2+redis3.2.8, 首先安装redis,确保redis正常运行,redis-cli能正常运行,运行后输入ping能够收到pong,向项目中pom.xml引入相关架包 redis.clients jedis 2.9.0 org.springframework.data spring-data-redis
Redis 和 spring 的整合
NULL 博文链接:https://1025358610.iteye.com/blog/2102583
redis与spring的整合
只是理解一下redis与spring整合的大概步骤,包括String,list,set,map格式的值
Redis Spring 整合 demo
NULL 博文链接:https://gwoham-163-com.iteye.com/blog/2216772
Spring Boot整合redis
Spring Boot 做的一个简单的增删改查,前台页面整合Thymeleaf模板,数据源druid,声明式事务,整合redis,并开启redis事务
Spring Cloud整合Redis
这是一个电商平台的项目实战案例,基于双11抢购活动真实需求设计,从需求分析到框架设计,从用户登录到抢购商品、完成支付等,这其中涉及千万级用户如何实现有序队列、如何进行高并发测试、用户唯一性判断等,该案例用细腻、详实的讲解,手把手教你完成全项目开发。
spring项目整合redis
spring项目整合redis 之前利用xml配置过spring-data-redis,但是在实际的项目中,兼容性不是很好。先在看一个实际项目中整合redis的案例。 1 首先pom.xml引入依赖 &amp;amp;lt;!--redis客户端 jedis--&amp;amp;gt; &amp;amp;lt;dependency&amp;amp;gt; &amp;amp;lt;groupId&amp;amp;gt;red...
Redis和Spring的整合包
Redis+spring-data-redis jar包Redis+spring-data-redis jar包Redis+spring-data-redis jar包
spring ibatis整合出错
[code=sql]org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [E:\workspace_n\hx\webapp\WEB-INF\classes\com\hx\core\user\dao\impl\UserDaoImpl.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlMapClient' is requiredrn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)rn at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)rn at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)rn at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)rn at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)rn at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)rn at javax.servlet.GenericServlet.init(GenericServlet.java:212)rn at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)rn at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)rn at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:516)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:578)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)rnCaused by: java.lang.IllegalArgumentException: Property 'sqlMapClient' is requiredrn at org.springframework.orm.ibatis.SqlMapClientTemplate.afterPropertiesSet(SqlMapClientTemplate.java:143)rn at org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.checkDaoConfig(SqlMapClientDaoSupport.java:109)rn at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)rn ... 32 more[/code]rnrn配置文件, 类文件 如下rn[code=java]rnpublic interface UserDao rnrn UserInfo getUserByLoginName(UserQo qo);rn rnrnrn@Component("userDao")rnpublic class UserDaoImpl extends SqlMapClientDaoSupport implements UserDao rn rn private final String selectUserByLoginName = "selectUserByLoginName";rnrn @Overridern public UserInfo getUserByLoginName(UserQo qo) rn return (UserInfo)getSqlMapClientTemplate().queryForObject(selectUserByLoginName, qo.getLoginName());rn rnrnrn[/code]rnrn文件位置:rn/hx/src/sqlmap/User.xmlrnrn[code=text] rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn select * from user_info ui where ui.loginName = #loginName# and ui.delFlag=0rn rn rn rn [/code]rnrn文件位置:rnrn/hx/src/applicationContext.xmlrnrn[code=text]rnrnrnrn rn rnrn rnrn rn rn classpath:jdbc.propertiesrn rn rn rnrn rnrn rn $jdbc.driverClassNamern rnrn rn $jdbc.urlrn rnrn rn $jdbc.usernamern rnrn rn $jdbc.passwordrn rn rnrn rn rn classpath:SqlMapConfig.xmlrn rnrn rn rn rn rnrn rn rn rn rn rnrnrnrn rnrn[/code]rn文件位置:rn/hx/src/SqlMapConfig.xmlrn[code=text]rn rn rnrn rn rn rn rnrn[/code]rn文件位置:rn/hx/src/com/hx/core/user/pojo/UserInfo.javarn[code=java]rnpublic class UserInfo extends BasePojo implements Serializable rn /**rn * rn */rn private static final long serialVersionUID = -289780747117628131L;rn rn private int id;rn private String fullName;rn private String loginName;rn private String password;rn private String cellPhone;rn private Date birthday;rn private String position;rn private String emailAddress;rn private String location;rn public int getId() rn return id;rn rn public void setId(int id) rn this.id = id;rn rn public String getFullName() rn return fullName;rn rn public void setFullName(String fullName) rn this.fullName = fullName;rn rn public String getLoginName() rn return loginName;rn rn public void setLoginName(String loginName) rn this.loginName = loginName;rn rn public String getPassword() rn return password;rn rn public void setPassword(String password) rn this.password = password;rn rn public String getCellPhone() rn return cellPhone;rn rn public void setCellPhone(String cellPhone) rn this.cellPhone = cellPhone;rn rn public Date getBirthday() rn return birthday;rn rn public void setBirthday(Date birthday) rn this.birthday = birthday;rn rn public String getPosition() rn return position;rn rn public void setPosition(String position) rn this.position = position;rn rn public String getEmailAddress() rn return emailAddress;rn rn public void setEmailAddress(String emailAddress) rn this.emailAddress = emailAddress;rn rn public String getLocation() rn return location;rn rn public void setLocation(String location) rn this.location = location;rn rn rnrn[/code]
spring jbpm整合出错 ?
在看了多位高手的帖子后,rn决定自己整合spring+jbpmrn但出错了。rnrnrn环境如下:rnrneclipse 3.2 +myeclipse 5.0 +hibernate3.0/3.2+jbpm3.1.4rnrnrnjunit 测试 出错 ,错误信息如下:rnrnrnrnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory0' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate collection role mapping org.jbpm.identity.Group.childrenrnorg.hibernate.DuplicateMappingException: Duplicate collection role mapping org.jbpm.identity.Group.childrenrn at org.hibernate.cfg.Mappings.addCollection(Mappings.java:123)rn at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1965)rn at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1940)rn at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:324)rn at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:238)rn at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:109)rn at org.hibernate.cfg.Configuration.add(Configuration.java:385)rn at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:426)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:679)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)rn at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:87)rn at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:72)rn at com.ltong.tax.common.AppContext.(AppContext.java:19)rn at com.ltong.tax.common.AppContext.getInstance(AppContext.java:12)rn at com.ltong.tax.common.AppContextTest.testGetInstance(AppContextTest.java:9)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:324)rn at junit.framework.TestCase.runTest(TestCase.java:154)rn at junit.framework.TestCase.runBare(TestCase.java:127)rn at junit.framework.TestResult$1.protect(TestResult.java:106)rn at junit.framework.TestResult.runProtected(TestResult.java:124)rn at junit.framework.TestResult.run(TestResult.java:109)rn at junit.framework.TestCase.run(TestCase.java:118)rn at junit.framework.TestSuite.runTest(TestSuite.java:208)rn at junit.framework.TestSuite.run(TestSuite.java:203)rn at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)rnrnrnrnhibernate 3.0 /3.2 都用过,rn都不行 ,rnrn请高手指教!rnrn
struts2 整合spring出错
首先我把struts2做了一个简单的登录的实现。没有出错 rn主要的代码和配置文件如下: rn-------------------- rnweb.xml rn------------------- rnrnrn代码rn rn rn rn rn struts2 rn rn org.apache.struts2.dispatcher.FilterDispatcher rn rn rn rn struts2 rn /* rn rn rn /login.jsp rn rn rnrnrn------------------------------- rnstruts.xml rn------------------------------- rnrn代码rn rn rn rn rn rn /index.jsp rn /error.jsp rn rn rn rn rn rn rnrnrn---------------- rnLoginAction rn----------------- rnrn代码rnpackage cn.ityc.action; rn rnpublic class LoginAction rn rn private String username; rn private String password; rn rn public String getUsername() rn return username; rn rn rn public void setUsername(String username) rn this.username = username; rn rn rn public String getPassword() rn return password; rn rn rn public void setPassword(String password) rn this.password=password; rn rn rn public String execute() throws Exception rn if(getUsername().equals("ityc")&&getPassword().equals("ityc")) rn return "error"; rn else rn return "success"; rn rn rn rnrnrn------------ rnlogin.jsp rn------------- rnrn代码rn rn<%@ page language="java" contentType="text/html;charset=GBK"%> rn rn rn 登录页面 rn rn rn rn rn 用户登陆 rn rn 用户名: rn rn rn 密 码: rn rn rn rn rn rn rn rn rn rnrnrn---------------------------- rn上面没有问题 rn然后我想把action用spring管理 rn------------------------ rn下面我在web.xml中添加以后 rn---------- rnweb.xml rn----------- rnrn代码rn rn rn rn rn struts2 rn rn org.apache.struts2.dispatcher.FilterDispatcher rn rn rn rn struts2 rn /* rn rn rn /login.jsp rn rn rn contextConfigLocation rn /WEB-INF/classes/applicationContext.xml rn rn rn SpringContextServlet rn org.springframework.web.context.ContextLoaderServlet rn 1 rn rn rnrnrn
Spring和Junit整合出错
今天在Spring4.3.9和Junit4.10整合出错 demo代码如下 package mo.project.transfer; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org...
spring boot整合redis及redis注解开发
spring boot整合redis 步骤一:导入pom依赖 &amp;lt;!-- redis与springboot 依赖 --&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;spring-boot-starter-data-...
Spring mvc整合redis实例(redis连接池)
Spring mvc整合redis实例(redis连接池) 将所有jedis 增删改进行事务的封装、查询单独做为有返回参数的封装。简化了很多代码
Redis之——Spring基于注解整合Redis
在《Redis之——Spring整合Redis》一文中,向大家介绍了如何将Spring与Redis整合起来,但不是基于注解的形式,很多同学都希望能够通过注解的形式来简单的将Spring与Redis整合起来,这样,在使用的时候,只需要在相应的方法上加上注解,便可以使方法轻松的调用Redis的缓存。那么今天就来向大家介绍如何用基于注解的形式来整合Spring与Redis。另外,在之前的一篇《Memca
Spring Data Redis整合Redis流程源码分析
一:版本信息如下.     1.1 SpringBoot的版本:1.5.10.RELEASE. &amp;lt;parent&amp;gt; &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;spring-boot-starter-parent&amp;lt;/artifactId&amp;gt; &amp;lt;versio...
redis的安装和使用【3】redis与spring的整合
本文将阐述如何把redis与spring集成。 1、前提约束 可以使用java调用redis服务 https://www.jianshu.com/p/83ef8a80508d 2、修改pom.xml 在pom.xml中加入以下依赖: &lt;dependency&gt; &lt;groupId&gt;org.apache.solr&lt;/grou...
redis 学习和使用spring 整合redis
      一。redis 官网: https://redis.io/download 1.1 客户端连接redis server API 使用jedis 连接redis 并使用其方法。     二。代码下载 java 连接redis 的代码:java-redis connection helloworld 三。参考资料 参看资料: http://www.runoob...
spring 整合redis的简单操作
spring 整合redis的简单操作 1 启动redis服务   进入redis服务目录下 执行命令 ./redis-server 2 建立一个maven项目  在pom文件中配置依赖 junit junit 4.12 test org.springframework spring-test 4.1.3.RELEASE
spring和redis相关操作的整合
版本要求:Spring 5.x,spring-data-redis 2.0.x,jedis 2.9 maven: &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;redis.clients&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;jedis&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;2.9.0&amp;...
Redis的使用--(二)与Spring的整合
主题词:使用Jedis、项目整合Redis 项目中整合jedis和spring框架: 设计一个相关接口(把String和Hash类型常用方法进行封装) 完成两个相关实现类(jedisPool的实现和jedisCluster的实现:属性注入) 完成spring-jedis.xml(将jedisPool的实现和jedisCluster的实现进行注入操作) 具体内容参看代码实现 需求:在tt-co
redis整合Spring 需要jar包
spring 整合redis 需要jar 文件 详情:https://blog.csdn.net/Keith003/article/details/81003557
spring和redis整合异常整理
记录 1、Unable to validate object异常信息如下:org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Coul
Spring boot与Redis的整合使用
关于Redis的安装与集群部署,可以参考《Linux下Redis的集群部署》 一、Redis的单机使用 (1) 新建gradle项目,依赖如下: dependencies { compile 'org.springframework.boot:spring-boot-starter-web' compile ('org.springframework.boot:spring...
Spring SpringMVC Mybatis 整合 Redis
Spring SpringMVC Mybatis 整合 Redis .........................................................................................
第五篇:Spring Boot整合Redis
Redis 是一个高性能的key-value数据库它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。使用redis作为缓存技术方案,主要是redis缓存技术的特点就在于高效,因为目前涉及的数据量逐渐增多,在对于数据的存储上面和sql以及服务器资源优化上面就来的特别的重要。而redi...
spring和redis整合集成步骤
spring和redis整合集成步骤一、准备工作1、 已经安装好redis服务 (windows 版,linux 版都可以)2、 依赖jar: jedis-2.9.0.jar 、 commons-pool2-2.5.0.jar 二、java中操作 (单机版--jedis操作)/** * @description: 单机版--jedis操作 * @param: * * @create...
redis与java spring的整合使用
redis是什么不用介绍了,很多朋友都清楚,至于怎么安装和配置redis,这里就不说了。看看怎么和spring整合在一起使用吧。 要在JAVA中使用redis。需要添加两个jar包:jedis-2.7.2.jar、commons-pool2-2.2.jar。(可以到网上下载,版本可以和这里不一样) 工程中先添加一个redis的属性配置文件: redis.propert
redis主从复制+哨兵整合spring
redis整合,采用了spring-data-redis很大程度上方便了我们操作redis的操作. pom依赖 &amp;lt;spring-data-redis.version&amp;gt;1.8.1.RELEASE&amp;lt;/spring-data-redis.version&amp;gt; &amp;lt;jedis.version&amp;gt;2.9.0&amp;lt;/jedis.versio...
Spring项目整合redis插件
第一步   注入Maven依赖 &amp;lt;!--redis配置--&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.springframework.data&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;spring-data-commons&amp;lt;/artifactId&amp;gt; &amp;lt;versio...
Redis整合spring版本问题
Redis整合spring版本问题 一开始使用 &lt;!-- https://mvnrepository.com/artifact/redis.clients/jedis --&gt;&lt;dependency&gt; &lt;groupId&gt;redis.clients&lt;/groupId&gt; &lt;artifactId&gt;jedis&lt;/artifac...
spring boot、 mybaits、 spring security、 redis整合
spring boot、 mybaits、 spring security、 redis整合
spring boot,mybaits,spring security,redis整合
spring boot,mybaits,spring security,redis整合
spring和hibernate整合过程出错
在MyEclipse下整合了Struts 1.3,Spring 2.5,Hibernate 3.2.rn并且利用MyEclipse的反向工程创建了User,UserDAO两个文件。rn当我使用UserDAO里面的方法:rn[code=Java]public void save(User transientInstance) rn log.debug("saving User instance");rn try rn getHibernateTemplate().save(transientInstance);rn log.debug("save successful");rn catch (RuntimeException re) rn log.error("save failed", re);rn throw re;rn rn [/code]rnrn[code=Java]public void save(User transientInstance) rn log.debug("saving User instance");rn try rn getHibernateTemplate().save(transientInstance);rn log.debug("save successful");rn catch (RuntimeException re) rn log.error("save failed", re);rn throw re;rn rn rnrnpublic List findByNickName(String nickNamern ) rn return findByProperty(NICK_NAME, nickNamern );rn [/code]rnrn使用这两个方法时不会出错,但是使用下面的方法时,却出错了。不知道为什么?rn[code=Java]public User findById( java.lang.Long id) rn log.debug("getting User instance with id: " + id);rn try rn User instance = (User) getHibernateTemplate()rn .get("User", id);rn return instance;rn catch (RuntimeException re) rn log.error("get failed", re);rn throw re;rn rn [/code]rnrn而出错提示是这样的。rn2008-9-23 10:43:07 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet action threw exceptionrnorg.hibernate.MappingException: Unknown entity: Userrn at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)rn at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:68)rn at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)rn at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)rn at org.springframework.orm.hibernate3.HibernateTemplate$2.doInHibernate(HibernateTemplate.java:547)rn at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)rn at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)rn at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:541)rn at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:535)rn at com.meixun.dao.impl.UserDAOImpl.findById(UserDAOImpl.java:68)rn at com.meixun.service.impl.UserServiceImpl.findById(UserServiceImpl.java:63)rn at com.meixun.struts.action.ProfileAction.execute(ProfileAction.java:47)rn at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)rn at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)rn at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)rn at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)rn at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)rn at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)rn at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)rn at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)rn at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:270)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:191)rn at com.meixun.filter.RequestEncodingFilter.doFilter(RequestEncodingFilter.java:78)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:220)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:191)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:227)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:211)rn at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:866)rn at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:705)rn at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1486)rn at java.lang.Thread.run(Thread.java:619)rnrn根据提示应该是找不到实体类,也就是User类,可是我检查了,好像都配置好了呀。为什么会这样呢?rn
Spring和MyBatis整合出错记录
有时在配置文件过程中会为了方便配置了统一别名。在映射xml中使用全称一般在加载bean时不出错,但要使用别名需注意。存在继承关系的bean可采用统一别名类型,但如果还有单一bean存在此时resultType用map或者全名。总而言之,处理MyBatis返回类型是要特别注意类型名称。不然会出现 org.apache.ibatis.builder.BuilderException:这样异常。
Struts2整合 Spring,出错,求救!
011-5-27 18:17:26 org.apache.catalina.core.StandardContext listenerStartrn严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerrnorg.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)rn at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)rn at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4336)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)rnCaused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]rn at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:118)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)rn ... 36 morern2011-5-27 18:17:26 org.apache.catalina.core.StandardContext startrn严重: Error listenerStartrn2011-5-27 18:17:26 org.apache.catalina.core.StandardContext startrn严重: Context [/Struts2_Hibernate] startup failed due to previous errorsrn2011-5-27 18:17:26 org.apache.catalina.core.ApplicationContext logrn信息: Closing Spring root WebApplicationContextrnlog4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).rnlog4j:WARN Please initialize the log4j system properly.rn2011-5-27 18:17:27 org.apache.catalina.core.ApplicationContext logrn信息: Initializing Spring root WebApplicationContextrn2011-5-27 18:17:27 org.apache.catalina.core.StandardContext listenerStartrn严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerrnorg.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)rn at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)rn at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4336)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1023)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1015)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:448)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:552)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)rnCaused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]rn at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:117)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)rn ... 36 morern2011-5-27 18:17:27 org.apache.catalina.core.StandardContext startrn严重: Error listenerStartrn2011-5-27 18:17:27 org.apache.catalina.core.StandardContext startrn严重: Context [/Struts2_Spring] startup failed due to previous errorsrn2011-5-27 18:17:27 org.apache.catalina.core.ApplicationContext logrn信息: Closing Spring root WebApplicationContextrn2011-5-27 18:17:27 org.apache.coyote.http11.Http11Protocol startrn信息: Starting Coyote HTTP/1.1 on http-8080rn2011-5-27 18:17:27 org.apache.jk.common.ChannelSocket initrn信息: JK: ajp13 listening on /0.0.0.0:8009rn2011-5-27 18:17:27 org.apache.jk.server.JkMain startrn信息: Jk running ID=0 time=0/30 config=nullrn2011-5-27 18:17:27 org.apache.catalina.startup.Catalina startrn信息: Server startup in 3034 msrnrnrnrn出现这样的错误,啥方法都用过了!就是弄不出来啊!!!网望大牛们帮帮忙!谢谢!
相关热词 c# 标准差 计算 c#siki第五季 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池