简体   繁体   English

spring boot无法运行 - 启动时出现IllegalAccessError

[英]spring boot fails to run - IllegalAccessError on startup

I have a strange issue and that I have not been able to resolve. 我有一个奇怪的问题,我无法解决。 I am trying to use the sample JPA sprint boot (v0.5.0-M6) project as a starting point for an application I am writing. 我正在尝试使用示例JPA sprint boot(v0.5.0-M6)项目作为我正在编写的应用程序的起点。 I grabbed the JPA sample and got that to run locally. 我抓住了JPA样本并让它在本地运行。 I then proceeded to add my code into that project. 然后我继续将我的代码添加到该项目中。 I imported into eclipse and run as spring-boot. 我导入了eclipse并以spring-boot运行。 Then I get this error: 然后我收到这个错误:

Exception in thread "main" java.lang.IllegalAccessError: tried to access class org.springframework.core.io.DefaultResourceLoader$ClassPathContextResource from class org.springframework.boot.context.embedded.EmbeddedWebApplicationContext
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getResourceByPath(EmbeddedWebApplicationContext.java:386)
at org.springframework.core.io.DefaultResourceLoader.getResource(DefaultResourceLoader.java:100)
at org.springframework.context.support.GenericApplicationContext.getResource(GenericApplicationContext.java:211)
at org.springframework.boot.context.initializer.ConfigFileApplicationContextInitializer.load(ConfigFileApplicationContextInitializer.java:192)
at org.springframework.boot.context.initializer.ConfigFileApplicationContextInitializer.load(ConfigFileApplicationContextInitializer.java:134)
at org.springframework.boot.context.initializer.ConfigFileApplicationContextInitializer.initialize(ConfigFileApplicationContextInitializer.java:121)
at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:403)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:287)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:749)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:738)

From what I can tell, this is the wrong application context, since I am not using XML configuration but annotations to drive the configuration. 据我所知,这是错误的应用程序上下文,因为我没有使用XML配置,而是使用注释来驱动配置。 Spring boot is automatically selecting this one and I need to tell it not to use the above. Spring boot会自动选择这个,我需要告诉它不要使用上面的内容。 At least that is what I think I need to do. 至少这是我认为我需要做的。

I did search here and in the spring.io forums but no one seems to have the same issue. 我在这里和spring.io论坛上搜索过,但似乎没有人有同样的问题。

Question: What drives the selection of an application context with the auto configuration? 问题:使用自动配置选择应用程序上下文的原因是什么?

What should I be looking at to resolve the above issue? 我应该考虑解决上述问题? What else do I need to provide to here help debug the auto configuration issue? 我还需要提供什么来帮助调试自动配置问题?

TIA, TIA,

Scott 斯科特

I got the same problem. 我遇到了同样的问题。 if you use maven check your pom.xml 如果你使用maven检查你的pom.xml

remove conflict version in Spring Lib. 删除Spring Lib中的冲突版本。

<properties>
       <hibernate.version>4.2.0.Final</hibernate.version>
       <mysql.connector.version>5.1.21</mysql.connector.version>
       <spring.version>3.2.2.RELEASE</spring.version>
</properties>

i remove this line 我删除这一行

<spring.version>3.2.2.RELEASE</spring.version>

and in maven dependency just 并且在maven依赖中

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
</dependency>

Hope this help. 希望这有帮助。

I was facing the same problem, and solved fixing the referencing to the boot-starter-parent pom. 我遇到了同样的问题,并解决了将引用修复为boot-starter-parent pom的问题。

At the pom.xml file I used: 在我使用的pom.xml文件中:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>0.5.0.M6</version>
</parent>

I have some urgent issues to fix now, so I didn't inspected this parent pom to see what's so important here, but I hope this can help you - don't forget to verify the version you're using! 我现在有一些紧急问题需要解决,所以我没有检查这个父pom,看看这里有什么重要,但我希望这可以帮助你 - 不要忘记验证你正在使用的版本!

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

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