Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run spring boot shadow jar , getting no ServletWebServerFactory bean defined in the context. #899

Open
souvmitra opened this issue Jan 31, 2024 · 1 comment

Comments

@souvmitra
Copy link

Please check the User Guide before submitting "how do I do 'x'?" questions!

Shadow Version

id 'com.github.johnrengelman.shadow' version '8.1.1'

Gradle Version

Expected Behavior

The jar should run and start up the spring boot project

Actual Behavior

Web application could not be started as there was no org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context.

Gradle Build Script(s)

Script


plugins {
id 'java'
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.1.4'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'org.springframework.boot.experimental.thin-launcher' version '1.0.31.RELEASE'
}

apply plugin: 'org.springframework.boot'
apply plugin: 'org.springframework.boot.experimental.thin-launcher'

//assemble.dependsOn = [thinJar]
//assemble.dependsOn = [shadowJar]

import com.github.jengelman.gradle.plugins.shadow.transformers.*

shadowJar {
archiveClassifier = 'aws'
manifest {
attributes 'Main-Class': 'com.alcon.parseImplantedIOLRecords.ParseImplantedIolRecordsApplication'
}
// Required for Spring
mergeServiceFiles()
append 'META-INF/spring.handlers'
append 'META-INF/spring.schemas'
append 'META-INF/spring.tooling'
append 'META-INF/spring-configuration-metadata.json'
transform(PropertiesFileTransformer) {
paths = ['META-INF/spring.factories']
mergeStrategy = "append"
}
configurations = [project.configurations.compileClasspath]

}

group = 'com.alcon'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenLocal()
maven { url 'https://repo.spring.io/milestone' }
}

ext {
set('springCloudVersion', "2023.0.0")
}

dependencies {

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-function-web'
implementation 'org.springframework.cloud:spring-cloud-function-adapter-aws:4.0.4'
implementation 'org.springframework.security:spring-security-core:6.1.2'
implementation 'io.awspring.cloud:spring-cloud-starter-aws-secrets-manager-config:2.4.4'
implementation 'org.springframework.boot:spring-boot-starter-validation:3.1.2'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'
implementation 'software.amazon.awssdk:ses:2.20.109'
implementation 'software.amazon.awssdk:sdk-core:2.20.109'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:4.0.3'
implementation 'software.amazon.awssdk:dynamodb-enhanced:2.20.109'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'com.google.guava:guava:31.1-jre'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.14.2'


compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

}

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

tasks.named('test') {
useJUnitPlatform()
}



### Content of Shadow JAR (`jar tf <jar file>` - post link to GIST if too long)
[Uploading shadow_jar_content.txt…]()
@souvmitra
Copy link
Author

shadow_jar_content.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant