简体   繁体   English

使用Spring IDE在Eclipse中编译时的NoSuchMethodError

[英]NoSuchMethodError when compiling in Eclipse with Spring IDE

I have a development environment based on Eclipse Juno with Spring IDE installed. 我有一个基于Eclipse Juno的开发环境,安装了Spring IDE。 My project uses also Spring Security. 我的项目也使用Spring Security。 The Spring version I am using is 2.5.5 and Spring Security is at 2.0.6. 我使用的Spring版本是2.5.5,Spring Security是2.0.6。 Now, after updating Spring IDE from 3.1.0 to 3.3.0, I am getting a NoSuchMethodError when Spring compiler is trying to compile this line: 现在,在将Spring IDE从3.1.0更新到3.3.0之后,当Spring编译器尝试编译这一行时,我得到一个NoSuchMethodError:

<security:authentication-provider user-service-ref="userDetailsService" />

<bean id="userDetailsService" class="com.mycompany.security.MyUserDetailsService">
    <property name="daoFactory" ref="DaoFactory" />
</bean>

MyUserDetailsService implements UserDetailsService and InitializingBean . MyUserDetailsS​​ervice实现UserDetailsServiceInitializingBean

schemaLocation for the file has been defined as: 该文件的schemaLocation已定义为:

xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/security 
        http://www.springframework.org/schema/security/spring-security-2.0.6.xsd"

The stacktrace looks like this: stacktrace看起来像这样:

!MESSAGE Error occured processing '/Server/WEB-INF/business-layer-context.xml'
!STACK 0
java.lang.NoSuchMethodError: org.springframework.beans.factory.support.BeanDefinitionBuilder.addConstructorArg(Ljava/lang/Object;)Lorg/springframework/beans/factory/support/BeanDefinitionBuilder;
at org.springframework.security.config.AuthenticationProviderBeanDefinitionParser.parse(AuthenticationProviderBeanDefinitionParser.java:88)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver$ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.java:177)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1400)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1330)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:494)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:402)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:388)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:445)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

When compiling the application with Ant script and starting the server, everything works fine, so the problem is limited to Eclipse and Spring IDE. 使用Ant脚本编译应用程序并启动服务器时,一切正常,因此问题仅限于Eclipse和Spring IDE。 Both my Ant and Eclipse configurations use the same Spring library. 我的Ant和Eclipse配置都使用相同的Spring库。 addConstructorArg method still seems to exist in the newest version of Spring, so I am puzzled by this error. addConstructorArg方法似乎仍然存在于最新版本的Spring中,所以我对此错误感到困惑。 What could be causing this problem? 什么可能导致这个问题?

I believe this is because Spring Tools Suite comes with it's own spring libraries. 我相信这是因为Spring Tools Suite附带了它自己的spring库。 So for the XML parsing and validation it does not use libraries on your project classpath. 因此,对于XML解析和验证,它不会在项目类路径上使用库。

Please see STS-3679 请参阅STS-3679

Check your XML configuration files for both Spring and Spring security. 检查XML配置文件以获取Spring和Spring安全性。 Do you have correct URLs in xsi:schemaLocation, like: 你在xsi:schemaLocation中有正确的URL,例如:

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM