spring boot app初始化失败

时间:2016-07-18 21:32:10

标签: spring-boot

在pom.xml中添加spring boot依赖项并运行spring boot app会导致以下错误 -

> xception in thread "main" java.lang.IllegalAccessError: tried to
> access method
> org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(Ljava/lang/Class;Ljava/lang/ClassLoader;)Ljava/util/List;
> from class org.springframework.boot.SpringApplication     at
> org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:392)
>   at
> org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:384)
>   at
> org.springframework.boot.SpringApplication.initialize(SpringApplication.java:260)
>   at
> org.springframework.boot.SpringApplication.<init>(SpringApplication.java:236)
>   at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
>   at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
>   at com.catalina.platform.batch.Application.main(Application.java:12)

请参阅下面我的pom.xml的快照

<dependencyManagement>
     <dependencies>
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.3.6.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-ftp</artifactId>
        <version>${spring.ftp.version}</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.1.3</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.1.3</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

2 个答案:

答案 0 :(得分:1)

通常IllegalAccessError问题是由于Maven引入了错误的Spring版本。 Spring Boot 1.3.6需要Spring Framework 4.2.7

spring-boot-dependencies dependencyManagement导入通常足以确保使用正确的版本,并且您发布的POM的有限部分看起来是正确的。

我建议运行mvn dependency:tree以检查是否正在插入正确的版本。还要检查您是否使用了最新的Maven版本。

如果做不到这一点,那么重现问题的项目将有助于追踪原因。

答案 1 :(得分:0)

当我创建一个Spring Simple Web Maven项目并在我的pom.xml中添加一些其他依赖项来为spring boot应用程序编写Web服务时,我也遇到了同样的问题

更新我的依赖项以便处理版本不匹配,然后执行Run As - &gt; Maven clean,Run As - &gt; Maven安装后跟Maven - Update Project在我的案例中工作