java.lang.NoSuchMethodError:org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver:方法<init>()找不到V

时间:2016-12-23 12:58:37

标签: spring hibernate spring-mvc resteasy spring-bean

我正在开发 Spring + MVC + RestEasy 示例。我成功地开发了代码,但是我看到了以下错误。看起来依赖性不匹配的问题。我已经煞费苦心地解决了这个问题,但还是无法修复它。我在此处上传了源代码: https://github.com/test512/RestEasy-Spring-MVC-Hibernate

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver: method <init>()V not found
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1582)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    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:778)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:666)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:632)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:680)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:551)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:492)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1238)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1151)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1038)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5337)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NoSuchMethodError: org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver: method <init>()V not found
    at org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver.<init>(PathVariableMethodArgumentResolver.java:68)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.getDefaultArgumentResolvers(RequestMappingHandlerAdapter.java:591)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.afterPropertiesSet(RequestMappingHandlerAdapter.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    ... 29 more

Dec 23, 2016 6:25:19 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [springmvc-hibernate-resteasy] in web application [/RestEasy-Spring-MVC-Hibernate] threw load() exception
java.lang.NoSuchMethodError: org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver: method <init>()V not found
    at org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver.<init>(PathVariableMethodArgumentResolver.java:68)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.getDefaultArgumentResolvers(RequestMappingHandlerAdapter.java:591)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.afterPropertiesSet(RequestMappingHandlerAdapter.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    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:778)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:666)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:632)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:680)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:551)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:492)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1238)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1151)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1038)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5337)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

的pom.xml

<modelVersion>4.0.0</modelVersion>
    <groupId>in.bench.resources</groupId>
    <artifactId>RestEasy-Spring-MVC-Hibernate</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <name>RestEasy-Spring-MVC-Hibernate</name>
    <description>RestEasy : Integrating with Spring-MVC-Framework and Hibernate ORM</description>


    <properties>
        <resteasy.version>3.0.8.Final</resteasy.version>
        <resteasy.scope>compile</resteasy.scope>        <!-- compile(Tomcat) / provided(JBoss) -->
        <spring.version>4.2.8.RELEASE</spring.version> <!-- 4.x doesn't work with RestEasy directly -->
        <hibernate.version>4.3.11.Final</hibernate.version>
        <mysql.version>5.1.32</mysql.version>
        <validation-api.version>1.1.0.Final</validation-api.version>
        <hibernate-validator.version>5.1.3.Final</hibernate-validator.version>

        <servlet.version>3.1.0</servlet.version>
        <jstl.version>1.2</jstl.version>
        <compileSource>1.7</compileSource>
        <maven.compiler.target>1.7</maven.compiler.target>
        <maven.compiler.source>1.7</maven.compiler.source>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <logback.version>1.1.3</logback.version>
        <jcl.slf4j.version>1.7.12</jcl.slf4j.version>
    </properties>



    <dependencies>
        <!-- RESTEasy JAX RS Implementation -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
            <version>${resteasy.version}</version>
            <scope>${resteasy.scope}</scope>
        </dependency>

        <!-- Resteasy Servlet Container Initializer -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-servlet-initializer</artifactId>
            <version>${resteasy.version}</version>
            <scope>${resteasy.scope}</scope>
        </dependency>

        <!-- Resteasy JAXB Provider -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxb-provider</artifactId>
            <version>${resteasy.version}</version>
            <scope>${resteasy.scope}</scope>
        </dependency>

        <!-- Resteasy Jackson Provider -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson-provider</artifactId>
            <version>${resteasy.version}</version>
            <scope>${resteasy.scope}</scope>
        </dependency>

        <!-- RESTEasy JAX RS Client -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>${resteasy.version}</version>
            <scope>${resteasy.scope}</scope>
        </dependency>

        <!-- Resteasy Spring Integration -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-spring</artifactId>
            <version>${resteasy.version}</version>
        </dependency>

        <!-- Spring Framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.10.5.RELEASE</version>
        </dependency>


        <!-- Hibernate Core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>


        <!-- Validations -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>${validation-api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${hibernate-validator.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>3.2.4</version>
        </dependency>

        <!-- MySql-Connector -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- servlet-3.1.0 -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${servlet.version}</version>
        </dependency>

        <!-- JSTL for JSP pages -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${jcl.slf4j.version}</version>
        </dependency>

        <!-- 3. logback -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>jboss</id>
            <url>http://repository.jboss.org/maven2</url>
        </repository>
    </repositories>

    <build>
        <finalName>RestEasy-Spring-MVC-Hibernate</finalName>

        <!-- maven compiler plugin -->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <!-- JAXB plugin to generate-sources from XSD -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>xjc</goal><!-- xjc/generate -->
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/generated/java/source</outputDirectory>
                            <schemaDirectory>${basedir}/src/main/resources/com/resteasy/series/spring/mvc/hibernate/service/entities</schemaDirectory>
                            <schemaFiles>*.xsd</schemaFiles>
                            <schemaLanguage>XMLSCHEMA</schemaLanguage>
                            <extension>true</extension>
                            <args>
                                <arg>-XtoString</arg>
                            </args>
                            <plugins>
                                <plugin>
                                    <groupId>org.jvnet.jaxb2_commons</groupId>
                                    <artifactId>jaxb2-basics</artifactId>
                                    <version>0.6.4</version>
                                </plugin>
                            </plugins>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

用SpringMVC-冬眠-RestEasy的-servlet.xml中

<?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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!-- Import basic SpringMVC Resteasy integration -->
    <import resource="classpath:springmvc-resteasy.xml" />

    <context:property-placeholder location="classpath:database.properties" />

    <!-- to activate annotations in beans already registered in the ApplicationContext -->
    <context:annotation-config />

    <jpa:repositories base-package="com.resteasy.series.spring.mvc.hibernate.repository" />

    <!-- to activate MVC annotation -->
    <mvc:annotation-driven />

    <!-- scans packages to find and register beans within the ApplicationContext -->
    <context:component-scan base-package="com.resteasy.series.spring.mvc.hibernate.*" />

    <!-- turn on spring transaction annotation -->
    <tx:annotation-driven transaction-manager="transactionManager" />

    <!-- Transaction Manager -->
    <bean id="transactionManager"  class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>


    <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="showSql" value="true"/>
        <property name="generateDdl" value="true"/>
        <property name="database" value="MYSQL"/>
    </bean>

    <!-- Session Factory -->
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
        <property name="packagesToScan" value="com.resteasy.series.spring.mvc.hibernate.model"/>

        <property name="jpaProperties">
            <props>
                <prop key="hibernate.hbm2ddl.auto">${mysql.hibernate.hbm2ddl.auto}</prop>
                <prop key="hibernate.dialect">${mysql.hibernate.dialect}</prop>
            </props>
        </property>

    </bean>

    <!-- dataSource configuration -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${mysql.driverClassName}" />
        <property name="url" value="${mysql.url}" />
        <property name="username" value="${mysql.username}" />
        <property name="password" value="${mysql.password}" />
    </bean>

    <!-- view resolver -->
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
</beans>

如果您需要任何其他详细信息,请与我们联系。我真的需要帮助。我认为这是使用resteasy + spring时非常典型的问题。不是吗?

依赖树:

[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ RestEasy-Spring-MVC-Hibernate ---
[INFO] in.bench.resources:RestEasy-Spring-MVC-Hibernate:war:1.0
[INFO] +- org.jboss.resteasy:resteasy-jaxrs:jar:3.0.8.Final:compile
[INFO] |  +- org.jboss.resteasy:jaxrs-api:jar:3.0.8.Final:compile
[INFO] |  +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] |  +- javax.activation:activation:jar:1.1:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.2.1:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.2.1:compile
[INFO] |  |  +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |  |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO] |  +- commons-io:commons-io:jar:2.1:compile
[INFO] |  \- net.jcip:jcip-annotations:jar:1.0:compile
[INFO] +- org.jboss.resteasy:resteasy-servlet-initializer:jar:3.0.8.Final:compile
[INFO] |  \- org.jboss.resteasy:async-http-servlet-3.0:jar:3.0.8.Final:compile
[INFO] +- org.jboss.resteasy:resteasy-jaxb-provider:jar:3.0.8.Final:compile
[INFO] |  \- com.sun.xml.bind:jaxb-impl:jar:2.2.7:compile
[INFO] |     +- com.sun.xml.bind:jaxb-core:jar:2.2.7:compile
[INFO] |     |  +- javax.xml.bind:jaxb-api:jar:2.2.7:compile
[INFO] |     |  \- com.sun.istack:istack-commons-runtime:jar:2.16:compile
[INFO] |     \- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.12:compile
[INFO] |        \- javax.xml.bind:jsr173_api:jar:1.0:compile
[INFO] +- org.jboss.resteasy:resteasy-jackson-provider:jar:3.0.8.Final:compile
[INFO] |  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.12:compile
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.12:compile
[INFO] |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.12:compile
[INFO] |  \- org.codehaus.jackson:jackson-xc:jar:1.9.12:compile
[INFO] +- org.jboss.resteasy:resteasy-client:jar:3.0.8.Final:compile
[INFO] +- org.jboss.resteasy:resteasy-spring:jar:3.0.8.Final:compile
[INFO] |  \- org.jboss.resteasy:resteasy-jettison-provider:jar:3.0.8.Final:compile
[INFO] |     \- org.codehaus.jettison:jettison:jar:1.3.2:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.2.8.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.2.8.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.2.8.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:4.2.8.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:4.2.8.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:4.2.8.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.2.8.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.10.5.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-commons:jar:1.12.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-orm:jar:4.2.8.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:4.2.8.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.2.8.RELEASE:compile
[INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.aspectj:aspectjrt:jar:1.8.9:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.3.11.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
[INFO] |  +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO] |  \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.3.11.Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.1.3.Final:compile
[INFO] |  \- com.fasterxml:classmate:jar:1.0.0:compile
[INFO] +- org.hibernate:hibernate-ehcache:jar:4.3.11.Final:compile
[INFO] |  \- net.sf.ehcache:ehcache-core:jar:2.4.3:compile
[INFO] +- cglib:cglib:jar:3.2.4:compile
[INFO] |  +- org.ow2.asm:asm:jar:5.1:compile
[INFO] |  \- org.apache.ant:ant:jar:1.9.6:compile
[INFO] |     \- org.apache.ant:ant-launcher:jar:1.9.6:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.8.5:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.32:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] +- jstl:jstl:jar:1.2:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile
[INFO] \- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO]    \- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.697s
[INFO] Finished at: Fri Dec 23 18:59:14 IST 2016
[INFO] Final Memory: 12M/494M
[INFO] ------------------------------------------------------------------------

2 个答案:

答案 0 :(得分:0)

我有同样的问题。我的错误是我忘了将@Autowired注释添加到构造函数中。

在我的特定情况下,我尝试使用最终字段配置CommandLineRunner,该字段是@Service类。

将@Autowired注释正确添加到MyCommandLineRunner后,异常消失了。

答案 1 :(得分:-1)

您可以通过清理项目,清理Tomcat和清理Tomcat Work目录来解决问题。另外,请确保您的pom.xml中没有包含不同版本Spring的多个jar文件。