我有一个在我的机器上运行完美的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
1条答案
按热度按时间jv4diomz1#
尝试在build.gradle中添加此内容