gpt4 book ai didi

java - java.lang.NoSuchMethodError:org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh

转载 作者:太空宇宙 更新时间:2023-11-04 10:42:12 25 4
gpt4 key购买 nike

我正在使用spring 3.2.6 RELEASE并将此登录配置放入xml后出现错误:

<http auto-config="true">
<intercept-url pattern="/login.html" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern="/loginFailed.html" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern="/**" access="ROLE_USER"/>
<form-login login-page="/login.html" authentication-failure-url="/loginFailed.html"/>
</http>


这是我的 pom.xml

<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>3.2.6.RELEASE</version>
</dependency>




尝试访问网址时出错:


  java.lang.NoSuchMethodError:
  org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh(Lorg / springframework / beans / factory / annotation / InjectionMetadata; Ljava / lang / Class;)Z
    在
  org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:317)
    在
  org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:285)
    在
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:870)
    在
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:495)
    在
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    在
  org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:296)
    在
  org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    在
  org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    在
  org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
    在
  org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:786)
    在
  org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:467)
    在
  org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
    在
  org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
    在
  org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
    在
  org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
    在
  org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
    在
  org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    在javax.servlet.GenericServlet.init(GenericServlet.java:158)在
  org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1174)
    在
  org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1090)
    在
  org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:770)
    在
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133)
    在
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    在
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    在
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    在
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    在
  org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
    在
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    在
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    在
  org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:417)
    在
  org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    在
  org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:754)
    在
  org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1376)

最佳答案

您的依赖项中使用的是哪个版本的spring-beanss-xxx。

在3.0.x版本中找不到needsRefresh()方法。它是在Spring 4.0.x中添加的。

您需要运行:

mvn dependency:analyze


或查看所有依赖项

mvn dependency:tree


如果同一个库具有多个版本,则类加载器可以选择找到的第一个库,因此请排除所有不必要的依赖项。

如果没有任何效果,请删除您的.m2目录,然后再次运行。有时候,行家会欺骗你:)

关于java - java.lang.NoSuchMethodError:org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48849638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com