2013-07-11 38 views
1

我有一個基於Eclipse Juno並安裝了Spring IDE的開發環境。我的項目也使用Spring Security。我使用的Spring版本是2.5.5,Spring Security是2.0.6。現在,從3.1.0更新Spring IDE的到3.3.0後,我得到當春編譯器嘗試編譯這條線的NoSuchMethodError:使用Spring IDE在Eclipse中編譯時的NoSuchMethodError

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

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

MyUserDetailsS​​ervice實現UserDetailsServiceInitializingBean

的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" 

堆棧跟蹤看起來是這樣的:

!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) 

當編譯與Ant腳本中的應用,並啓動服務器,一切工作正常,所以該問題僅限於Eclipse和Spring IDE。我的Ant和Eclipse配置都使用相同的Spring庫。 addConstructorArg方法似乎仍然存在於最新版本的Spring中,所以我對這個錯誤感到困惑。什麼可能導致這個問題?

+0

您正在使用哪種版本的彈簧? – sreeprasad

+0

@jax我在該問題中添加了'userDetailsS​​ervice' bean。 – Carlos

+0

@SREEPRASAD GOVINDANKUTTY 2.5.5如問題所述。 – Carlos

回答

2

我相信這是因爲春天工具套件,用它自己的春天庫。因此,對於XML解析和驗證,它不會在您的項目類路徑中使用庫。

請參閱STS-3679

+0

謝謝,這完美地解釋了它! – Carlos

1

檢查您的XML配置文件的Spring和Spring安全。 你有在XSI正確的URL:的schemaLocation,如:

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

我相信如此。我將schemaLocation部分添加到了我的問題中。 – Carlos

相關問題