我使用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>
尝试访问url时出现
错误:
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh(Lorg / springframework的/豆类/工厂/注解/ InjectionMetadata; Ljava /郎/类;)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)at 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)
答案 0 :(得分:0)
你的依赖项中有什么版本的spring-beanss-xxx。
在3.0.x版本中找不到needsRefresh()方法。它是在Spring 4.0.x中添加的。
您需要运行:
mvn dependency:analyze
或查看所有依赖项
mvn dependency:tree
如果您有相同lib的多个版本,则类加载器可以选择它找到的第一个版本,因此排除所有不必要的依赖项。
如果无效,请删除.m2目录并再次运行。有时maven欺骗你:))