3

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"
}
Community
  • 1
  • 1
Anil Bhaskar
  • 3,718
  • 4
  • 33
  • 51

1 Answers1

1

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

Benjamin Muschko
  • 32,442
  • 9
  • 61
  • 82
  • thanks! what should it be. My main function is in `Application.java` – Anil Bhaskar Jul 16 '15 at 15:48
  • 1
    Run `gradle installDist` to create an image of the application in `build/install/projectName`. You'll find the scripts there. – Benjamin Muschko Jul 16 '15 at 21:03
  • @BenjaminMuschko it gave me a scripts that is around 150 lines long. i am new to this can u tell me how to start the application with those generated start scripts. – Raj Singh Jan 04 '22 at 08:46