繁体   English   中英

升级 gradle 和 spring 引导版本后,Spring 引导 kafka 应用程序未作为控制台应用程序启动

[英]Spring boot kafka application is not start as console app after upgrading gradle and spring boot version

升级细节。 Spring 启动:2.2.7-RELEASE 到 2.4.6 gradle:4.10.3 到 6.9.2

build.gradle

plugins{
   id 'org.springframework.boot' version '2.4.6'
   id 'io.spring.dependency-management' version '1.0.11.RELESE'
   id 'java'
}
sourceCompatibility ='1.8'

dependency-management{
    import {
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:2020.0.4"
    }
}
dependencies{
              implmentation 'org.springframework.boot:spring-boot-starter-data-jdbc'
              implmentation 'org.springframework.boot:spring-boot-starter-web'
              implmentation 'org.springframework.kafka:spring-kafka'
              implmentation 'org.projectlombok.lombok'
              testImplmentation 'org.springframework.boot:spring-boot-starter-test'
              implmentation 'org.springframework.cloud:spring-cloud-starter-config'
              implmentation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
              compile 'org.springframework.boot:spring-boot-starter-webflux'
              implmentation 'org.springframework.boot:spring-boot-starter-data-jpa'
              compile(group: 'org.springframework.boot', name: 'spring-boot-configuaration-processor')
              compile(group: 'com.microsoft.sqlserver', name: 'mssql-jdbc' version: '8.3.1.jre8-preview')
              runtimeOnly 'com.microsoft.sqlserver:mysql-jdbc'
              implmentation 'io.springfox:springfox-swagger2:2.9.2'
              implmentation 'io.springfox:springfox-swagger-ui:2.9.2'
              compile 'org.springframework.boot:spring-boot-starter-actuator'
              compile 'org.projectreactor:reactor-spring'
              implmentation 'io.micrometer:micrometer-registry-prometheus'
              implmentation 'javax.mail:mail:1.4'
              testImplmentation 'junit:junit'
              annotationProcessor 'org.projectlombok:lombok'
              
}
wrapper{
  distribuationUrl = "https://services.gradle.org/distributions/gradle-6.9.2-bin"

}

主要 class:

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
@EnableKafka
@EnableScheduling
public class SpringBootMainClassApplication {
    public static void main(String[] args) {
    
        SpringApplication.run(SpringBootMainClassApplication.class, args);
    }
}

应用程序.properties

server.port=8080

错误:“ApplicationContextException:由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext”。

在此处输入图像描述

将以下属性添加到 application.properties 后,代码运行良好。

spring.main.web-application-type=none

应用程序作为控制台应用程序运行良好,无需将 spring.main.web-application-type=none 更改为旧版本 spring boot 2.2.7-RELEASE 的属性,您能否帮助我们运行应用程序而不添加新属性?

它工作正常,看来你的 gradle 有很多错误

请使用这个 gradle,永远喜欢你的代码,就像一幅画一样美丽:)

plugins {
  id "io.spring.dependency-management" version "1.0.11.RELEASE"
  id "org.springframework.boot" version "2.4.6"
  id "java"
}

sourceCompatibility ='1.8'

repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
    mavenCentral()
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:2020.0.4"
    }
}

dependencies
{
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jdbc'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
    implementation group: 'org.springframework.kafka', name: 'spring-kafka'
    
    implementation 'io.springfox:springfox-swagger2:2.9.2'
    implementation 'io.springfox:springfox-swagger-ui:2.9.2'
    implementation 'org.springframework.cloud:spring-cloud-starter-config'
    implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'io.micrometer:micrometer-registry-prometheus'
    implementation 'javax.mail:mail:1.4'
    
    compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.24'
    compileOnly group: 'org.springframework.boot', name: 'spring-boot-configuaration-processor'
    compileOnly group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '8.3.1.jre8-preview'
    
    compileOnly 'org.springframework.boot:spring-boot-starter-webflux'
    compileOnly 'org.springframework.boot:spring-boot-starter-actuator'
    compileOnly 'org.projectreactor:reactor-spring'
    
    runtimeOnly 'com.microsoft.sqlserver:mysql-jdbc'
    
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'junit:junit'
    
    annotationProcessor 'org.projectlombok:lombok'
}

暂无
暂无

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

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