Gradle:通过gradle任务boot创建的jar不能正常工作

时间:2018-10-10 13:13:18

标签: java gradle spring-data-neo4j

我正在创建具有以下属性的Spring Boot应用程序,当我使用Gradle bootrun运行项目时,该项目运行成功;但是,当我创建一个jar并将其部署在这里无法正常运行时,则是​​build.gradle

我检查了项目的所有版本是否相同。

Error :Error mapping to ad-hoc class .. At present, only @Result types that are discovered by the domain entity package scanning can be mapped.;
nested exception is org.neo4j.ogm.exception.core.MappingException: Error mapping to ad-hoc class com.vipul....  At present, only @Result types that are discovered by the domain entity package scanning can be mapped

PS:我知道关于查询结果的映射,但是它可以与bootRun一起使用,但不能与bootJar一起使用

buildscript {
  ext {
    springBootVersion = '2.0.5.RELEASE'
    swaggerVersion = '2.5.0'
    jacksonVersion = '2.9.2'
    projectVersion = "0.0.1"
    version = "0.0.1"
  }
  repositories {
    mavenCentral()
    jcenter()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  }
}

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"
apply plugin: 'idea'
apply plugin: 'application'
version = "$projectVersion-SNAPSHOT"
sourceCompatibility = 1.8
mainClassName = 'com.vipul.Application'
applicationDefaultJvmArgs = ["-Xdiag"]
repositories {
  mavenCentral()
  jcenter()
  maven { url "https://plugins.gradle.org/m2/" }
  maven{ url "https://repo.spring.io/plugins-release"}
}
task wrapper(type: Wrapper) { gradleVersion = '4.4' }

ext {
    springCloudVersion = 'Finchley.RELEASE'
}

dependencies {
  compile('org.springframework.boot:spring-boot-starter-aop')
  compile('org.springframework.boot:spring-boot-starter-cache')
  compile('org.springframework.boot:spring-boot-starter-data-neo4j')
}

dependencyManagement {
  imports {
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
  }
}

1 个答案:

答案 0 :(得分:2)

尝试在build.gradle中更改springBoot和springCloud版本

**

springBootVersion='2.0.0.RELEASE'

**

春季启动版本似乎有问题。 springBootVersion ='2.0.5.RELEASE'