【问题标题】:Gradle Test Fails in CircleCI- Could not find symbols for Lombok Generated CodeCircleCI 中的 Gradle 测试失败-找不到 Lombok 生成代码的符号
【发布时间】:2019-06-20 10:33:36
【问题描述】:

我有一个带有 Gradle 的 Spring Boot 应用程序。我尝试升级到 Spring Boot 2.1.0.RELEASE。我还必须像这样在gradle-wrapper.properties 中升级 Gradel Wrapper:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip

我的代码使用 Lombok 1.18.2

在本地,我的应用程序测试运行正常。但是,CircleCI 构建失败,就像这样。

!/bin/bash -eo pipefail

分级测试

任务:编译Java /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:31:错误:找不到符号 categoryRepository.save(Category.builder() ^ 符号:方法 builder() 地点:班级类别 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:34:错误:找不到符号 categoryRepository.save(Category.builder() ^ 符号:方法 builder() 地点:班级类别 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:37:错误:找不到符号 categoryRepository.save(Category.builder() ^ 符号:方法 builder() 地点:班级类别 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:40:错误:找不到符号 categoryRepository.save(Category.builder() ^ 符号:方法 builder() 地点:班级类别 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:43:错误:找不到符号 categoryRepository.save(Category.builder() ^ 符号:方法 builder() 地点:班级类别 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:48:错误:找不到符号 vendorRepository.save(Vendor.builder() ^ 符号:方法 builder() 地点:类供应商 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:52:错误:找不到符号 vendorRepository.save(Vendor.builder() ^ 符号:方法 builder() 地点:类供应商 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:56:错误:找不到符号 vendorRepository.save(Vendor.builder() ^ 符号:方法 builder() 地点:类供应商 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:60:错误:找不到符号 vendorRepository.save(Vendor.builder() ^ 符号:方法 builder() 地点:类供应商 /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:64:错误:找不到符号 vendorRepository.save(Vendor.builder() ^ 符号:方法 builder() 地点:类供应商 10 个错误

任务:编译Java失败

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

BUILD FAILED in 3s
1 actionable task: 1 executed
Exited with code 1

请帮忙。

【问题讨论】:

  • 您是否能够在本地执行gradle buildgradle test 而不会出现问题?当我在本地运行 gradle buildtest 时,我在本地遇到相同的错误,但如果我在本地使用 ./gradlew build./gradlew test,它会工作。

标签: spring-boot lombok circleci


【解决方案1】:

尝试更改gradle 并使用config.ymlsteps: 部分下的./gradlew 作为以下模板:

version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/openjdk:8-jdk

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4

    working_directory: ~/repo

    environment:
      # Customize the JVM maximum heap limit
      JVM_OPTS: -Xmx3200m
      TERM: dumb

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "build.gradle" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run: ./gradlew dependencies # <-- changed from `gradle dependencies`

      - save_cache:
          paths:
            - ~/.gradle
          key: v1-dependencies-{{ checksum "build.gradle" }}

      # run tests!
      - run: ./gradlew test # <-- changed from `gradle test`

【讨论】:

    【解决方案2】:

    对我有用的是在 build.gradle 依赖项中添加“annotationProcessor”(它也没有在本地构建)。

    dependencies {
       compileOnly 'org.projectlombok:lombok'
       annotationProcessor 'org.projectlombok:lombok'
    }
    

    【讨论】:

      猜你喜欢
      • 2019-08-21
      • 1970-01-01
      • 2021-03-01
      • 2023-03-12
      • 2011-10-23
      • 1970-01-01
      • 2019-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多