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
Java 接收方类o.s.c.b.BootstrapApplicationListener$CloseContextOnFailureApplicationListener未定义或继承impl_Java_Spring Boot_Gradle_Spring Boot Gradle Plugin - Fatal编程技术网

Java 接收方类o.s.c.b.BootstrapApplicationListener$CloseContextOnFailureApplicationListener未定义或继承impl

Java 接收方类o.s.c.b.BootstrapApplicationListener$CloseContextOnFailureApplicationListener未定义或继承impl,java,spring-boot,gradle,spring-boot-gradle-plugin,Java,Spring Boot,Gradle,Spring Boot Gradle Plugin,我在运行项目时遇到了这个错误。我无法知道错误的原因,也无法在线找到解决方案。 此项目正在另一台笔记本电脑上运行,没有任何错误,但当我提取zip并尝试运行它时,发现它抛出错误。 请帮我弄清楚。谢谢 错误 任务“:Application.main()”的执行失败。 进程'command'/home/jamshaid/Documents/idea-IC-192.5728.98/jbr/bin/java''以非零出口值1结束 StackTrace 2019-08-11 09:57:06,589 2269

我在运行项目时遇到了这个错误。我无法知道错误的原因,也无法在线找到解决方案。 此项目正在另一台笔记本电脑上运行,没有任何错误,但当我提取zip并尝试运行它时,发现它抛出错误。 请帮我弄清楚。谢谢
错误

任务“:Application.main()”的执行失败。 进程'command'/home/jamshaid/Documents/idea-IC-192.5728.98/jbr/bin/java''以非零出口值1结束

StackTrace

2019-08-11 09:57:06,589 2269 [main] INFO  com.techno.homes.Application - No active profile set, falling back to default profiles: default
2019-08-11 09:57:06,628 2308 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.AbstractMethodError: Receiver class org.springframework.cloud.bootstrap.BootstrapApplicationListener$CloseContextOnFailureApplicationListener does not define or inherit an implementation of the resolved method abstract getOrder()I of interface org.springframework.core.Ordered.
    at org.springframework.core.OrderComparator.findOrder(OrderComparator.java:142)
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:65)
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:125)
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:113)
    at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:82)
    at org.springframework.core.OrderComparator.compare(OrderComparator.java:68)
    at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
    at java.base/java.util.TimSort.sort(TimSort.java:220)
    at java.base/java.util.Arrays.sort(Arrays.java:1515)
    at java.base/java.util.ArrayList.sort(ArrayList.java:1749)
    at org.springframework.boot.SpringApplication.asUnmodifiableOrderedSet(SpringApplication.java:1325)
    at org.springframework.boot.SpringApplication.getListeners(SpringApplication.java:1234)
    at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85)
    at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:394)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:328)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
    at com.techno.homes.Application.main(Application.java:24)
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
apply plugin: 'docker'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'}

buildscript {
project.ext {
    springBootVersion = '2.0.4.RELEASE'
    jarName = 'recipe'
    versionName = '1.0.0'
    gradleDockerVersion = '1.2'
    swagger2version = '2.9.2'
 }

repositories {
    jcenter()
    maven { url "https://repo.maven.apache.org/maven2" }
}
dependencies {
    classpath "org.springframework.boot:spring-boot-gradle-    plugin:${project.springBootVersion}"
    classpath "se.transmode.gradle:gradle-docker:${project.gradleDockerVersion}"
}
}

task createWrapper(type: Wrapper) {
gradleVersion = '4.4.1'
}


// Used by the Docker gradle plugin, group refers to the account under which the docker image is created
group = 'com.techno.homes'
mainClassName = 'com.techno.homes.Application'
sourceCompatibility = 11
targetCompatibility = 11


repositories {
mavenCentral()
jcenter()
}

ext {
springCloudVersion = 'Greenwich.SR2'
}

dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.4.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.0.4.RELEASE'
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.16.Final'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web-services', version: '2.0.4.RELEASE'
compile group: 'ma.glasnost.orika', name: 'orika-core', version: '1.4.6'
compile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.springframework.boot', name: 'spring-boot-test-autoconfigure', version: '2.0.4.RELEASE'
compile group: 'org.springframework', name: 'spring-test', version: '5.1.8.RELEASE'
compile(group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.4.3.Final')
compile(group: 'org.hibernate', name: 'hibernate-core', version: '5.2.17.Final')
compile group: 'org.springframework.boot', name: 'spring-boot-test'
compile group: 'org.mockito', name: 'mockito-core', version: '2.15.0'
 compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.4'
compile group: 'info.cukes', name: 'cucumber-core', version: '1.2.4'
compile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.4'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '2.0.1'
 compile group: 'com.spotify', name: 'docker-maven-plugin', version: '1.2.0'
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
runtime group: 'mysql', name: 'mysql-connector-java', version: '5.1.46'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testCompile group: 'com.github.tomakehurst', name: 'wiremock', version: '1.58'
testCompile group: 'info.cukes', name: 'cucumber-spring', version: '1.2.5'


// Basic Spring boot with config client
//   compile('org.springframework.cloud:spring-cloud-starter-config')
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")

// Spring OAuth2 security
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.security.oauth:spring-security-oauth2")
//  compile("org.springframework.security:spring-security-jwt")
 compile group: 'org.springframework.security', name: 'spring-security-jwt', version: '1.0.10.RELEASE'

  // Eureka client
  //  compile('org.springframework.cloud:spring-cloud-starter-eureka')
 compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-client', version: '2.0.0.RELEASE'

// Zipkin tracing
//compile('org.springframework.cloud:spring-cloud-starter-zipkin')
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zipkin', version: '2.1.2.RELEASE'

// Swagger for API testing
compile("io.springfox:springfox-swagger2:${swagger2version}")
compile("io.springfox:springfox-swagger-ui:${swagger2version}")
compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-config', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-web', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.3.6.RELEASE'

compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'


//camel
compile group: 'org.apache.camel', name: 'camel-spring-boot', version: '2.15.1'
compile group: 'org.apache.camel', name: 'camel-pulsar', version: '2.24.1'
compile group: 'org.apache.camel', name: 'camel-core', version: '2.24.1'

compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9.3'


}


 jar {
baseName = "${project.jarName}"
version = "${project.versionName}"
enabled = true
manifest {
    attributes 'Main-Class': 'com.techno.homes.Application'
}
}
渐变文件

2019-08-11 09:57:06,589 2269 [main] INFO  com.techno.homes.Application - No active profile set, falling back to default profiles: default
2019-08-11 09:57:06,628 2308 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.AbstractMethodError: Receiver class org.springframework.cloud.bootstrap.BootstrapApplicationListener$CloseContextOnFailureApplicationListener does not define or inherit an implementation of the resolved method abstract getOrder()I of interface org.springframework.core.Ordered.
    at org.springframework.core.OrderComparator.findOrder(OrderComparator.java:142)
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:65)
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:125)
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:113)
    at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:82)
    at org.springframework.core.OrderComparator.compare(OrderComparator.java:68)
    at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
    at java.base/java.util.TimSort.sort(TimSort.java:220)
    at java.base/java.util.Arrays.sort(Arrays.java:1515)
    at java.base/java.util.ArrayList.sort(ArrayList.java:1749)
    at org.springframework.boot.SpringApplication.asUnmodifiableOrderedSet(SpringApplication.java:1325)
    at org.springframework.boot.SpringApplication.getListeners(SpringApplication.java:1234)
    at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85)
    at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:394)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:328)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
    at com.techno.homes.Application.main(Application.java:24)
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
apply plugin: 'docker'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'}

buildscript {
project.ext {
    springBootVersion = '2.0.4.RELEASE'
    jarName = 'recipe'
    versionName = '1.0.0'
    gradleDockerVersion = '1.2'
    swagger2version = '2.9.2'
 }

repositories {
    jcenter()
    maven { url "https://repo.maven.apache.org/maven2" }
}
dependencies {
    classpath "org.springframework.boot:spring-boot-gradle-    plugin:${project.springBootVersion}"
    classpath "se.transmode.gradle:gradle-docker:${project.gradleDockerVersion}"
}
}

task createWrapper(type: Wrapper) {
gradleVersion = '4.4.1'
}


// Used by the Docker gradle plugin, group refers to the account under which the docker image is created
group = 'com.techno.homes'
mainClassName = 'com.techno.homes.Application'
sourceCompatibility = 11
targetCompatibility = 11


repositories {
mavenCentral()
jcenter()
}

ext {
springCloudVersion = 'Greenwich.SR2'
}

dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.4.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.0.4.RELEASE'
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.16.Final'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web-services', version: '2.0.4.RELEASE'
compile group: 'ma.glasnost.orika', name: 'orika-core', version: '1.4.6'
compile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.springframework.boot', name: 'spring-boot-test-autoconfigure', version: '2.0.4.RELEASE'
compile group: 'org.springframework', name: 'spring-test', version: '5.1.8.RELEASE'
compile(group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.4.3.Final')
compile(group: 'org.hibernate', name: 'hibernate-core', version: '5.2.17.Final')
compile group: 'org.springframework.boot', name: 'spring-boot-test'
compile group: 'org.mockito', name: 'mockito-core', version: '2.15.0'
 compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.4'
compile group: 'info.cukes', name: 'cucumber-core', version: '1.2.4'
compile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.4'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '2.0.1'
 compile group: 'com.spotify', name: 'docker-maven-plugin', version: '1.2.0'
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
runtime group: 'mysql', name: 'mysql-connector-java', version: '5.1.46'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testCompile group: 'com.github.tomakehurst', name: 'wiremock', version: '1.58'
testCompile group: 'info.cukes', name: 'cucumber-spring', version: '1.2.5'


// Basic Spring boot with config client
//   compile('org.springframework.cloud:spring-cloud-starter-config')
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")

// Spring OAuth2 security
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.security.oauth:spring-security-oauth2")
//  compile("org.springframework.security:spring-security-jwt")
 compile group: 'org.springframework.security', name: 'spring-security-jwt', version: '1.0.10.RELEASE'

  // Eureka client
  //  compile('org.springframework.cloud:spring-cloud-starter-eureka')
 compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-client', version: '2.0.0.RELEASE'

// Zipkin tracing
//compile('org.springframework.cloud:spring-cloud-starter-zipkin')
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zipkin', version: '2.1.2.RELEASE'

// Swagger for API testing
compile("io.springfox:springfox-swagger2:${swagger2version}")
compile("io.springfox:springfox-swagger-ui:${swagger2version}")
compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-config', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-web', version: '5.1.5.RELEASE'
compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.3.6.RELEASE'

compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'


//camel
compile group: 'org.apache.camel', name: 'camel-spring-boot', version: '2.15.1'
compile group: 'org.apache.camel', name: 'camel-pulsar', version: '2.24.1'
compile group: 'org.apache.camel', name: 'camel-core', version: '2.24.1'

compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9.3'


}


 jar {
baseName = "${project.jarName}"
version = "${project.versionName}"
enabled = true
manifest {
    attributes 'Main-Class': 'com.techno.homes.Application'
}
}
联盟

@Configuration
@EnableJpaAuditing
@EnableJpaRepositories("com.techno.homes.repositories")
@SpringBootApplication
@EnableEurekaClient
@EnableResourceServer
@EnableSwagger2
@EnableOAuth2Client
public class Application {

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

}
}

好的-在这里做了一些测试。 从start.spring.io创建了空的SpringBoot应用程序。 将项目导入IntelliJ

然后我加载了你的gradle文件内容。还从删除主(应用程序)类中的所有@imports开始——只保留@springbootplication。 删除了所有其他类(包括测试)。 我也犯了同样的错误。 首先,删除所有对Swagger和Hibernate等的gradle依赖项。运行裸体SpringBoot应用程序不需要这些依赖项。 删除此行已解决错误(不再抛出错误): 编译(“org.springframework.security.oauth:spring-security-oauth2”)

因此,如果您想执行SpringOAuth2,需要配置一些东西。。。让你找到

建议你一次添加一个小的构建块——你在SpringBoot主应用程序中有很多东西。Spring将尽其所能自动配置默认值,但您可能会遇到类似的问题。
添加一个注释-编写单元测试类,该类将验证该特定注释的基本功能。然后启用下一个,写单元测试。。。。所有单元都在使用基本测试覆盖率。

好-在这里进行了一些测试。 从start.spring.io创建了空的SpringBoot应用程序。 将项目导入IntelliJ

然后我加载了你的gradle文件内容。还从删除主(应用程序)类中的所有@imports开始——只保留@springbootplication。 删除了所有其他类(包括测试)。 我也犯了同样的错误。 首先,删除所有对Swagger和Hibernate等的gradle依赖项。运行裸体SpringBoot应用程序不需要这些依赖项。 删除此行已解决错误(不再抛出错误): 编译(“org.springframework.security.oauth:spring-security-oauth2”)

因此,如果您想执行SpringOAuth2,需要配置一些东西。。。让你找到

建议你一次添加一个小的构建块——你在SpringBoot主应用程序中有很多东西。Spring将尽其所能自动配置默认值,但您可能会遇到类似的问题。
添加一个注释-编写单元测试类,该类将验证该特定注释的基本功能。然后启用下一个,写单元测试。。。。所有单元都在使用基本测试覆盖率。

您的Spring Boot版本对于您的Spring Cloud版本来说太旧了:

SpringCloudGreenwich(2.1.x)与SpringBoot2.0.x和SpringFramework 5.0.x不兼容。要么更新spring boot,要么将spring cloud降级为Finchley

所以请将Spring Boot更新为2.1.x


注:搜索“BootstrapApplicationListener$CloseContextOnFailureApplicationListener”会让您马上找到:-)

您的Spring启动版本对于您的Spring云版本来说太旧了:

SpringCloudGreenwich(2.1.x)与SpringBoot2.0.x和SpringFramework 5.0.x不兼容。要么更新spring boot,要么将spring cloud降级为Finchley

所以请将Spring Boot更新为2.1.x


注:搜索“BootstrapApplicationListener$CloseContextOnFailureApplicationListener”会让您马上找到它:-)

这是因为spring和cloud版本不兼容

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

org.springframework.boot
spring启动程序父级
2.1.3.1发布
父版本应为升级版本或与云版本相同

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>

org.springframework.cloud
spring-cloud-starter-oauth2
2.1.3.1发布

这是因为spring和cloud版本不兼容

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

org.springframework.boot
spring启动程序父级
2.1.3.1发布
父版本应为升级版本或与云版本相同

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>

org.springframework.cloud
spring-cloud-starter-oauth2
2.1.3.1发布

我来看看。我的笔记本电脑与此应用程序有问题。它在我朋友的笔记本电脑上运行得很好。我刚把拉链拉出来,试着在我的笔记本电脑上运行。我会看看的。我的笔记本电脑与此应用程序有问题。它在我朋友的笔记本电脑上运行得很好。我刚把拉链拉出来,试着在我的笔记本电脑上运行。