2016-01-24 29 views
3

剛剛開始在我的Spring Boot啓動中獲取IllegalAccessError。IllegalAccessError在啓動時調用DefaultConversionService.addCollectionConverters()

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:269) 
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:241) 
    at org.springframework.boot.context.config.ConfigFileApplicationListener.bindToSpringApplication(ConfigFileApplicationListener.java:230) 
    at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:181) 
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:166) 
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:152) 
    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:325) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1124) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1113) 
    at biz.ianw.LanCheckerReloader.Application.main(Application.java:23) 

這似乎類似於issue with spring boot while upgrading to 1.3.0.RELEASE但我還沒有覆蓋我的春節版本:

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.3.1.RELEASE</version> 
</parent> 

<dependencies> 

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.jsoup</groupId> 
     <artifactId>jsoup</artifactId> 
     <version>1.8.3</version> 
    </dependency> 

    <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <version>2.4</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.commons</groupId> 
     <artifactId>commons-lang3</artifactId> 
     <version>3.4</version> 
    </dependency> 
</dependencies> 

春4.2.4-RELEASE似乎已經選定,其中包含DefaultConversionService.addCollectionConverters()方法。

我已經退出了我過去幾個小時的代碼更改,但仍然得到這個。

歡迎任何建議!

+0

在IDE中是否出現此錯誤?如果你嘗試(清理)並從命令行運行應用程序會怎麼樣? – fateddy

+0

你幾乎可以肯定在類路徑中有一些舊的Spring Jars。使用'-verbose:class'運行可以讓你看到正在加載的內容以及從哪裏開始 –

+0

看起來好像某些設置不正確的源文件共享必須將一些舊的Spring Jar拖放到新項目中。我不確定它是如何發生的,但是我將通用代碼重構爲一個沒有任何庫的新項目,並且包含了它,現在它們都可以工作。 我很想刪除這個問題,除非有人不同意? – Ian

回答

9

我有使用Spring Boot 1.3.3.RELEASE和Spring Framework 4.2.2.RELEASE相同的問題。我試圖逐個升級Spring Framework版本,並使用Spring Framework 4.2.5.RELEASE解決了這個問題。

希望這會有所幫助。

+0

這對我有效。 –

+0

帶4.2.5的spring boot 1.5.2也失敗了。升級到4.3.7解決了這個問題。 – marstone

3

我有同樣的問題。我有模塊化項目,其中一個模塊使用4.1.9春天版本。在另一個模塊My Spring引導版本是1.3.3和春天版本4.2.5。 「:類-verbose」

在VM參數通過上面的命令,並且類是從4.1.9加載,然後我有信息

,直到我用我並沒有意識到這個問題。

這幫助我調試是什麼問題。我已將其他項目依賴項更改爲4.2.5。

我認爲這個問題會在我們使用父pom的時候解決,如果我們在一個項目中有模塊的話。