'Spring boot kafka application is not start as console app after upgrading gradle and spring boot version
upgradation details. Spring boot : 2.2.7-RELEASE to 2.4.6 gradle: 4.10.3 to 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"
}
main 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);
}
}
application.properties
server.port=8080
Error: “ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean“.
Code running fine after adding below properties to application.properties.
spring.main.web-application-type=none
Application is working fine as console app without changing spring.main.web-application-type=none to properties with old version spring boot 2.2.7-RELEASE, Can you please help us to run application without adding new properties?
Solution 1:[1]
It is working fine, seems you gradle has lot of errors
Please use this gradle, always love your code as beautiful it could be like a painting :)
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'
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dickens A S |
