簡體   English   中英

Gradle構建成功,運行jar的錯誤

[英]Gradle build successful, error running jar

我是新手。

我正在使用gradle構建一個項目。 它成功構建沒有任何錯誤。 在運行構建jar文件時,它給出了classNotFoundException

在此輸入圖像描述

我正在從spring.io構建一個簡單的 spring項目

但問題看起來與類似,但無法找到解決方案。 請幫忙。

編輯:這是我的build.gradle看起來的樣子

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

您需要使用生成的啟動腳本啟動應用程序。 他們將自動負責設置正確的類路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM