【发布时间】:2022-01-07 13:19:39
【问题描述】:
我需要在Linux 上运行AWS EC2 我jar 文件。
我在Gradle 上有一个multi-project。
我知道我的问题有很多类似物,但我没有找到 multi-project 的任何内容。
我的项目结构如下
demo
-core
com.example
build.gradle
-web
build.gradle
com.example
DemoApplication.java(main)
build.gradle
我的build.gradle 在演示中。
plugins {
id 'org.springframework.boot' version '2.6.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
jar {
manifest {
attributes 'Main-class' : 'com.example.DemoApplication'
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-ldap'
implementation 'org.springframework.boot:spring-boot-starter-hateoas'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
当我执行命令 jar 时,我得到了在 Linux java -jar '/home/ec2-user/demo-0.0.1-SNAPSHOT-plain.jar' 上运行的 jar 文件,它给了我一个错误。
无法找到或加载主类 com.example.DemoApplication
【问题讨论】:
标签: java linux gradle amazon-ec2 jar