當我在idea中啟動應用程式時它運行良好但是當我嘗試從cmd啟動這個應用程式時java -jar build/libs/dev-0.0.1-SNAPSHOT.jar
我得到這個錯誤
21:02:06.634 [main] 錯誤 org.springframework.boot.SpringApplication - 應用程式運行失敗 java.lang.IllegalArgumentException:在 META-INF/spring.factories 中找不到自動配置類。如果您使用的是自定義包裝,請確保該檔案是正確的。
這是我的 build.gradle
/*
* This file was generated by the Gradle 'init' task.
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.6.7"
}
}
plugins {
id 'java'
id 'groovy'
id 'maven-publish'
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.7'
implementation 'org.springframework.boot:spring-boot-configuration-processor:2.6.7'
implementation 'org.springframework:spring-aop:5.3.19'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'com.vladmihalcea:hibernate-types-52:2.16.2'
implementation 'org.flywaydb:flyway-core:8.5.10'
runtimeOnly 'org.postgresql:postgresql:42.3.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.6.7'
testImplementation 'org.springframework.security:spring-security-test:5.6.3'
testImplementation 'org.codehaus.groovy:groovy-all:3.0.10'
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.1-groovy-3.0'
testImplementation 'org.testcontainers:spock:1.17.1'
testImplementation "org.testcontainers:postgresql:1.17.1"
}
group = 'com.dev'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
targetCompatibility = '17'
java.sourceCompatibility = JavaVersion.VERSION_17
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
compileJava {
options.compilerArgs = "-Amapstruct.defaultComponentModel=spring"
options.compilerArgs = "-Amapstruct.unmappedTargetPolicy=WARN"
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
'Main-Class': 'com.dev.DevApplication',
'Class-Path': configurations.runtimeClasspath.files.collect { "lib/$it.name" }.join(' ')
)
}
from{
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it)}
}
}
uj5u.com熱心網友回復:
所以我像這樣編輯了 build.gradle,它現在正在作業
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'groovy'
id 'maven-publish'
id 'org.springframework.boot' version '2.6.7'
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-security:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.7'
implementation 'org.springframework.boot:spring-boot-configuration-processor:2.6.7'
implementation 'org.springframework:spring-aop:5.3.19'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'com.vladmihalcea:hibernate-types-52:2.16.2'
implementation 'org.flywaydb:flyway-core:8.5.10'
runtimeOnly 'org.postgresql:postgresql:42.3.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.6.7'
testImplementation 'org.springframework.security:spring-security-test:5.6.3'
testImplementation 'org.codehaus.groovy:groovy-all:3.0.10'
testImplementation 'org.spockframework:spock-core:2.1-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.1-groovy-3.0'
testImplementation 'org.testcontainers:spock:1.17.1'
testImplementation "org.testcontainers:postgresql:1.17.1"
}
group = 'com.dev'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
targetCompatibility = '17'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
compileJava {
options.compilerArgs = "-Amapstruct.defaultComponentModel=spring"
options.compilerArgs = "-Amapstruct.unmappedTargetPolicy=WARN"
}
jar {
enabled = false
}
springBoot {
mainClass = 'com.dev.DevApplication'
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/473464.html
上一篇:方法超出編譯器指令限制
