升级到1.3.0.RELEASE时出现Spring Boot问题

5

你好,我刚将Spring Boot升级至1.3.0.RELEASE版本,但在运行时出现了奇怪的错误。

14:43:52.503 [main] INFO  c.test.whf.service.HfServices - Starting up....
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.support.DefaultConversionService.addCollectionConverters(Lorg/springframework/core/convert/converter/ConverterRegistry;)V from class org.springframework.boot.bind.RelaxedConversionService
    at org.springframework.boot.bind.RelaxedConversionService.<init>(RelaxedConversionService.java:52)
    at org.springframework.boot.bind.RelaxedDataBinder.modifyProperties(RelaxedDataBinder.java:148)
    at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:128)
    at org.springframework.validation.DataBinder.bind(DataBinder.java:715)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:267)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.bindToSpringApplication(ConfigFileApplicationListener.java:220)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:171)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:161)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:146)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119)
    at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:65)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:315)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101)
    at com.wellmanage.whf.service.HfServices.main(HfServices.java:97)

同时,我的代码中没有进行任何其他更改,不确定是什么原因导致这种情况。

应用程序类非常简单,如下所示:

  SpringApplication.run(HfServices.class, args);

Please help ...


2
我在使用Spring Boot 1.3.0和Spring 4.2.2时遇到了相同的错误。升级到Spring 4.2.3后,问题得到了解决。 - FVlad
2个回答

12

该方法是在Spring框架中添加的,您正在明确地覆盖项目中的版本。 不要这样做!

Spring Boot会为您管理它,并且您应该真正地让它确定要使用的Spring Framework版本。


1
感谢Stephane提供这个信息。我之前使用了4.2.2版本,因为在该版本中修复了一个问题(在里程碑1.3.0版本中有效)。现在我们是否应该让Spring Boot决定底层Spring框架的版本? - Gaurav Rawat
2
这一直是一个问题。如果你需要一个_更新的_版本(就像你所做的那样),那很好,但是一旦你升级了Spring Boot,你必须记得删除那个覆盖并让Spring Boot再次选择它。该方法是在4.2.3中添加的。 - Stephane Nicoll
啊,好的,谢谢。似乎logback也有一些变化,现在我的运行失败了,可能是由于logback问题,让我检查并解决一下。 - Gaurav Rawat

0

我之前也遇到过这个错误。我们目前正在使用WebLogic运行应用程序,并计划迁移到云端,同时启用Spring Boot运行。 要解决这个问题,我需要将以下内容添加到webapp/WEB-INF/weblogic.xml文件中:

<wls:container-descriptor>
    <wls:prefer-application-packages>
        <wls:package-name>org.springframework.*</wls:package-name>            
    </wls:prefer-application-packages>
</wls:container-descriptor>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接