首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >升级gradle和Spring启动版本之后,spring引导kafka应用程序不会作为控制台应用程序启动。

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

Stack Overflow用户
提问于 2022-04-21 14:41:42
回答 1查看 163关注 0票数 0

升级细节。弹簧引导:2.2.7-发布到2.4.6级: 4.10.3至6.9.2

build.gradle

代码语言:javascript
运行
复制
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"

}

主修班:

代码语言:javascript
运行
复制
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
@EnableKafka
@EnableScheduling
public class SpringBootMainClassApplication {
    public static void main(String[] args) {
    
        SpringApplication.run(SpringBootMainClassApplication.class, args);
    }
}

application.properties

代码语言:javascript
运行
复制
server.port=8080

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

在这里输入图像描述

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

代码语言:javascript
运行
复制
spring.main.web-application-type=none

应用程序作为控制台应用程序运行良好,而不需要将Spring.main.web应用程序类型=none更改为带有旧版本spring 2.2.7版本的属性,您能帮助我们在不添加新属性的情况下运行应用程序吗?

EN

回答 1

Stack Overflow用户

发布于 2022-04-21 16:56:21

它运转得很好,好像你有很多错误。

请使用这个等级,永远爱你的代码,因为它可能就像一幅画:)

代码语言:javascript
运行
复制
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'
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71956396

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档