无法实例化接口org.springframework.context.ApplicationContextInitializer

时间:2019-06-11 13:14:16

标签: java spring spring-boot gradle jar

我尝试使用命令运行jar文件:

java -jar CinemaServer.jar

但是我有错误:

   Exception in thread "main" java.lang.IllegalArgumentException: Cannot 
instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:450)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:429)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:268)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:249)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
    at app.Application.main(Application.java:10)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:275)
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:442)
    ... 7 more

我的gradle脚本:

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle- plugin:2.1.5.RELEASE")
 }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
  baseName = 'gs-rest-service'
  version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
  compile("org.springframework.boot:spring-boot-starter-web")
  testCompile('org.springframework.boot:spring-boot-starter-test')
  // https://mvnrepository.com/artifact/com.typesafe/config
  compile group: 'com.typesafe', name: 'config', version: '1.2.0'
  implementation 'com.google.code.gson:gson:2.8.5'
}

我的应用程序文件:

package app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }
}

我的项目结构:

how i try to build it

这:

project structure

因此,我还从this github repo添加了spring.factories文件

该如何解决? 我尝试阅读许多this之类的问题,但不适用于我。

使用google drive

的源代码加载zip文件

0 个答案:

没有答案