由于版本不兼容,STS 不会响应

STS won't respond due to version incompatibility

我的 STS 3.9.4.RELEASE (Build: 201804120921, Platform: Eclipse Oxygen.3a 4.7.3a) 经常因以下原因崩溃:

!ENTRY org.springframework.ide.eclipse.beans.core 1 0 2018-04-26 09:23:26.627
!MESSAGE Error occured processing '/project/WebContent/WEB-INF/context/security.xml'
!STACK 0
java.lang.NoSuchMethodError: org.springframework.beans.factory.support.BeanDefinitionBuilder.setSource(Ljava/lang/Object;)Lorg/springframework/beans/factory/support/BeanDefinitionBuilder;
    at org.springframework.security.config.ConcurrentSessionsBeanDefinitionParser.parse(ConcurrentSessionsBeanDefinitionParser.java:64)
    at org.springframework.security.config.HttpSecurityBeanDefinitionParser.registerConcurrentSessionControlBeansIfRequired(HttpSecurityBeanDefinitionParser.java:261)
    at org.springframework.security.config.HttpSecurityBeanDefinitionParser.parse(HttpSecurityBeanDefinitionParser.java:147)
    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:1410)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1434)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1400)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:172)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1363)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig.registerBeanDefinitions(BeansConfig.java:410)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig.loadBeanDefinitions(BeansConfig.java:394)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig.call(BeansConfig.java:453)
    at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig.call(BeansConfig.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

我的项目使用了spring-security-core:2.0.8.RELEASEspring-core:3.2.0.RELEASE,所以很明显我的项目使用的Spring版本与Spring的版本不兼容IDE 用于分析 bean。我试过了:

  1. 从配置文件中删除有问题的 bean xml (Project > Properties > Spring > Beans Support > Config Files > Remove above xml)
  2. 在我的项目上完全禁用 bean 验证 (Project > Properties > Spring > Project Validators > Uncheck Beans Validator)

但他们都没有帮助。此错误导致:

  1. 保存到冻结(说用户操作正在等待后台工作完成,但是有none)即使在多次重启后,
  2. shutdown/restart 的 STS 失败(它只是使 0 进度),迫使我终止进程

有什么办法可以解决这个问题吗?

不幸的是,看起来库的使用版本确实与 IDE 内部用于创建 beans 模型的 Spring 版本不兼容,因此删除有问题的 Spring XML 来自项目属性的配置文件是解决此问题的正确方法。

但看起来您的 XML 仍在用于创建内部 beans 模型。因此,请确保禁用自动配置文件检测机制,否则该机制会一遍又一遍地找到您的 XML 文件。