Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
spring引导无法运行-IllegalAccessError启动时出错_Spring_Spring Boot - Fatal编程技术网

spring引导无法运行-IllegalAccessError启动时出错

spring引导无法运行-IllegalAccessError启动时出错,spring,spring-boot,Spring,Spring Boot,我有一个奇怪的问题,我还没有解决。我试图使用示例JPA sprint boot(v0.5.0-M6)项目作为我正在编写的应用程序的起点。我抓取了JPA样本并在本地运行。然后我继续将代码添加到该项目中。我导入eclipse并作为spring boot运行。然后我得到这个错误: Exception in thread "main" java.lang.IllegalAccessError: tried to access class org.springframework.core.io.Defau

我有一个奇怪的问题,我还没有解决。我试图使用示例JPA sprint boot(v0.5.0-M6)项目作为我正在编写的应用程序的起点。我抓取了JPA样本并在本地运行。然后我继续将代码添加到该项目中。我导入eclipse并作为spring boot运行。然后我得到这个错误:

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)
据我所知,这是错误的应用程序上下文,因为我不是使用XML配置,而是使用注释来驱动配置。Spring boot会自动选择这一个,我需要告诉它不要使用上面的选项。至少这是我认为我需要做的

我在这里和spring.io论坛上搜索过,但似乎没有人有同样的问题

问题:是什么驱动了自动配置应用程序上下文的选择

我应该看什么来解决上述问题?我还需要提供什么来帮助调试自动配置问题

蒂亚

斯科特

我也有同样的问题。 如果使用maven,请检查pom.xml

删除Spring库中的冲突版本

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

4.2.0.4最终版本
5.1.21
3.2.2.1发布
我删除这条线

<spring.version>3.2.2.RELEASE</spring.version>
3.2.2.1版本
在maven依赖中

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

org.springframework
SpringJDBC

希望这对我有所帮助。

我也遇到了同样的问题,并解决了修复对启动程序父pom的引用的问题

在我使用的pom.xml文件中:

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

org.springframework.boot
spring启动程序父级
0.5.0.M6

我现在有一些紧急问题要解决,所以我没有检查这个父pom来了解什么是如此重要,但我希望这可以帮助您-不要忘记验证您正在使用的版本

java.lang.IllegalAccessError
通常是环境问题的标志。可能是类路径上的错误jar文件,或者是错误的JDK?很难说没有更多的细节。没有您的更改,样本工作正常吗?变化是什么?你能分享代码吗?你的回答让我找到了问题的解决办法。这是因为在我的多模块父POM中,我为SpringCore的特定版本(3.2.5)添加了一个依赖项。我不会想到这是问题的原因,但似乎是这样。谢谢你的帮助!这也帮了我很大的忙!在我的情况下,我还有一个多模块的父POM。在我的父POM中,我必须确保设置的版本与spring boot dependencies POM中的版本相同。