当前位置: 首页 > 知识库问答 >
问题:

无法为gradle项目创建JAR文件

司寇烨伟
2023-03-14

我想创建一个jar文件,我可以上传到AWS,但每次我运行命令'gradle jar'从命令提示符我得到以下错误。

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- 
debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

每当我在命令提示符中运行gradle清除时,我都会得到“构建成功”。下面是build.gradle内容:

buildscript {
ext {
    springBootVersion = '2.0.4.RELEASE'
}
repositories {
    mavenCentral()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath "net.ltgt.gradle:gradle-apt-plugin:0.18"
}
}



apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.ltgt.apt'

group = 'com.myproject.api'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_1_8


ext {
  lombokVersion = '1.16.20'
  mapstructVersion = '1.2.0.Final'
}

repositories {
    mavenCentral()
    mavenLocal()
    jcenter()
             flatDir {
                dirs 'libs'
        }


}

dependencies {

    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-mail')
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('org.springframework.data:spring-data-jpa')
    compile('io.springfox:springfox-swagger2:2.9.2')
    compile('io.springfox:springfox-swagger-ui:2.9.2')
    compile group: 'commons-io', name: 'commons-io', version: '2.6'


    compile group: 'org.json', name: 'json', version: '20180813'
    compile files('libs/checksum_2.0.0.jar')

    compileOnly("org.projectlombok:lombok:${lombokVersion}")
    compileOnly("org.mapstruct:mapstruct-jdk8:${mapstructVersion}")
    compileOnly("org.mapstruct:mapstruct-processor:${mapstructVersion}")

    runtime('org.springframework.boot:spring-boot-devtools')
    runtime('mysql:mysql-connector-java')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}


eclipse {
    classpath {
        file.whenMerged { cp ->
            cp.entries.add( new org.gradle.plugins.ide.eclipse.model.SourceFolder('build/generated/source/apt/ma 
   in', null) )
        }
    }
}

我需要添加插件吗?提前谢谢。请帮忙

共有2个答案

公冶才
2023-03-14

打开任务管理器并强制停止Java(TM)平台SE

C:\Users\{current user}\。gradle\caches\jars-9\jars-9。锁定文件

商麒
2023-03-14

我用的是“gradle clean”和“gradle build”,而不是“gradlew clean”和“gradlew build”。格拉德卢指挥部为我工作。

 类似资料:
  • 问题内容: 我是Flutter的新手,尝试在创建新项目时运行示例项目。尝试运行它时,出现以下问题: 失败:生成失败,发生异常。 其中:构建文件“ PROJECTPATH / android / app / build.gradle”行:25 出了什么问题:评估项目’:app’时发生问题。 无法解析配置“ classpath”的所有文件。找不到lint-gradle-api.jar(com.andr

  • 是否有教程解释如何正确创建Java Gradle项目并构建。jar文件? 当我创建Java项目并添加Gradle:File时- 或 我的项目在这一点上是如此的混乱,也许我应该创建另一个项目,然后将Main.class和Gradle的依赖关系从旧项目复制/粘贴到新项目上。 如果这是我的最佳选择,那么这次我如何正确创建项目?

  • 我使用spring mvc、gradle和Tomcat创建了一个java rest服务。我想从这个项目中创建一个war来部署在tomcat中,我想从所有模型包中创建一个jar。我设法制造了战争,而且效果很好。但是我不知道如何从指定的类中创建一个jar来用作客户端jar。我知道我必须使用include('com/a/b/**/model/**')来选择类,但仅此而已。这个jar我想安装在。M2本地回

  • 我试图通过在Eclipse中从Facets中分配“JPA facet”来将一个项目转换为启用JPA的项目。 但是,没有选择“JPA方面”的选项。 在分析之后,我发现我甚至不能用eclipse创建一个新的JPA项目,我正在使用eclipse创建一个新的JPA项目。 在这篇文章中,还提到了更新到新的Eclipse。但是,有没有什么方法可以找出现有的Eclipse中有什么问题。

  • 我想使用Eclipse和Gradle来构建POJO。我安装了Eclipse STS插件,正如Gradle教程中强调的那样。我使用文件创建带有Eclipse的Gradle项目

  • 我尝试使用gradle build的以下格式创建一个jar库,以便以后可以将其作为jar包导入该项目中的其他人。但是,生成的jar只有一个清单文件,没有java文件。 这些文件在Eclipse中的一个包中。 感恩节。