线程“main”中出现异常java.lang.NoClassDefFoundError:在www.example.com中部署railway.appspringBoot

qvtsj1bj  于 2023-04-19  发布在  Spring
关注(0)|答案(1)|浏览(97)

我有一个在我的机器上运行完美的Sping Boot 应用程序。我试图在www.example.com上部署它railway.app。构建是好的,但在部署时我得到这个错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
at com.lagalt.LagaltProjectApplication.main(LagaltProjectApplication.java:9)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
at java.base/jdk.internal.loader.BuiltinClass`your text`Loader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)

我有以下gradle.build文件:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.0.4'
    id 'io.spring.dependency-management' version '1.1.0'
}

// Apply the Spring Boot Gradle plugin
apply plugin: 'org.springframework.boot'

jar {
    manifest {
        attributes(

                'Main-Class': 'com.lagalt.LagaltProjectApplication'
        )
    }
}

group = 'com.lagalt'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

configurations {

    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'org.postgresql:postgresql'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-bo`your text`ot-starter-test'
}

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

有什么想法吗?
我删除了jar{},但出现错误无法找到主类

type here
jv4diomz

jv4diomz1#

尝试在build.gradle中添加此内容

jar {
    enabled = false
    manifest {
        attributes 'Main-Class': 'com.example.MainApplication'
    }
}

相关问题