java.lang.NoClassDefFoundError:org / jredis / JRedis

时间:2016-06-23 06:47:21

标签: spring-mvc redis

我有以下配置xml for redis

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!-- Redis Connection Factory -->
    <bean id="jredisConnectionFactory"
        class="org.springframework.data.redis.connection.jredis.JredisConnectionFactory"
        p:use-pool="true" p:host-name="server" p:port="6379" />

    <!-- Redis Template Configuration -->
    <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
        p:connection-factory-ref="jredisConnectionFactory" />

    <context:annotation-config />
    <context:component-scan base-package="com.hhl.main" />
    <context:spring-configured />

</beans>

我添加了maven依赖

<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.8.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
            <version>1.7.1.RELEASE</version>
        </dependency>

我收到以下错误。

  

java.lang.NoClassDefFoundError:org / jredis / JRedis at   java.lang.Class.getDeclaredMethods0(Native Method)〜[?:1.8.0_66] at   java.lang.Class.privateGetDeclaredMethods(Class.java:2701)   〜[?:1.8.0_66]在java.lang.Class.getDeclaredMethods(Class.java:1975)   〜[?:1.8.0_66] at   org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:572)   〜[spring-core-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:489)   〜[spring-core-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:475)   〜[spring-core-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:241)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1063)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1036)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:303)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)   〜[spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:759)   〜[spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)   〜[spring-context-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)   〜[spring-web-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)   [spring-web-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)   [spring-web-4.1.8.RELEASE.jar:4.1.8.RELEASE] at   org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)   [catalina.jar:7.0.62] at   org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)   [catalina.jar:7.0.62] at   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)   [catalina.jar:7.0.62] at   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1575)   [catalina.jar:7.0.62] at   org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1565)   [catalina.jar:7.0.62] at   java.util.concurrent.FutureTask.run(FutureTask.java:266)[?:1.8.0_66]     在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)   [?:1.8.0_66] at   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617)   [?:1.8.0_66]在java.lang.Thread.run(Thread.java:745)[?:1.8.0_66]   引起:java.lang.ClassNotFoundException:org.jredis.JRedis at   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)   〜[catalina.jar:7.0.62] at   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)   〜[catalina.jar:7.0.62] ... 30多2016年6月23日下午12:15:12   org.apache.catalina.core.StandardContext listenerStart SEVERE:   将上下文初始化事件发送到侦听器实例的异常   class org.springframework.web.context.ContextLoaderListener

0 个答案:

没有答案