我有一个springboot app。当我在我的windows机器上测试它的开发模式时,它工作得很完美。当我运行不同的方法来使jar可执行时(gradle build,./gradlew bootJar)也可以完美地使用 *java -jar /build/libs/.*jar命令。
但是,当我尝试将其部署到Linux服务器时,运行它编译的(gradle build,./gradlew bootJar)命令,但当执行它时,它给了我下一个错误:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'validaIndustriaAlmacenada': Unsatisfied dependency expressed through field 'dimDeudorRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DimDeudorRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class cxc.com.mx.cargadorCLIP.models.postgres.emisores.DimDeudorEntity
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
我的豆子上有Spring的注解。正如我提到的,如果我运行Windows jar,它就像幽灵一样工作。即使我在Linux服务器上运行Windows制作的jar也可以工作。它的jar使insde的Linux服务器失败。
这是我在windows机器上的环境
Gradle:
------------------------------------------------------------
Gradle 6.3
------------------------------------------------------------
Build time: 2020-03-24 19:52:07 UTC
Revision: bacd40b727b0130eeac8855ae3f9fd9a0b207c60
Kotlin: 1.3.70
Groovy: 2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_231 (Oracle Corporation 25.231-b11)
OS: Windows 10 10.0 amd64
JAVA
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
虽然这是Linux服务器环境
格雷德酒店
------------------------------------------------------------
Gradle 6.3
------------------------------------------------------------
Build time: 2020-03-24 19:52:07 UTC
Revision: bacd40b727b0130eeac8855ae3f9fd9a0b207c60
Kotlin: 1.3.70
Groovy: 2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_252 (Private Build 25.252-b09)
OS: Linux 4.15.0-99-generic amd64
JAVA
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~18.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode
gradle.build
plugins {
id 'org.springframework.boot' version '2.2.7.BUILD-SNAPSHOT'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'cxc.com.mx'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
dependencies {
// Getters y setters automaticos
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
// Development plugin, autorestart on changes
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
//SQL server
compile "com.microsoft.sqlserver:mssql-jdbc:8.3.0.jre8-preview"
// SQL
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-web'
compile group: 'com.vladmihalcea', name: 'hibernate-types-43', version: '2.7.1'
runtimeOnly 'org.postgresql:postgresql'
compile 'org.json:json:20171018'
compile "com.vladmihalcea:hibernate-types-52:2.9.9"
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
// for test
compile group: 'org.mockito', name: 'mockito-core', version: '2.13.0'
}
test {
useJUnitPlatform()
}
最后要提到的是,如果我在Linux服务器上运行./gradlew bootRun也可以工作。只是jar没有。在做jar之前也试过用gradle清洁。但还是失败了。
“对不起,如果我犯了英语语法或词汇错误,我还在学习语言:)”
1条答案
按热度按时间6xfqseft1#
尝试
./gradlew clean build
以生成