Gradle build successful, error running jar

こ雲淡風輕ζ 提交于 2019-12-13 13:51:37

问题


I am new to gradle.

I am building a project using gradle. It build successfully without any error. While running the build jar file it is giving classNotFoundException.

I am building a simple spring project from spring.io

However question look similar to this but, could not find a solution. Please help.

edit: This is how my build.gradle looks

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
    baseName = 'gs-rest-service'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("junit:junit")
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

startScripts {
  mainClassName = 'Application'
}

springBoot {
  mainClass = "Application"
}

回答1:


You'll need to start the application with the generated start scripts. They will automatically take care of setting up the proper classpath.



来源:https://stackoverflow.com/questions/31434623/gradle-build-successful-error-running-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!