Anil Bhaskar
Anil Bhaskar

Reputation: 3978

Gradle build successful, error running jar

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.

enter image description here

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"
}

Upvotes: 3

Views: 1413

Answers (1)

Benjamin Muschko
Benjamin Muschko

Reputation: 33476

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

Upvotes: 1

Related Questions