LoginSignup
2
0

More than 5 years have passed since last update.

lombokをGradleでインストールできない。

Last updated at Posted at 2019-04-05

事象

Gradleに下記の2行追加して、Gradle実行したがエラーが出る。

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('com.jayway.jsonpath:json-path')
    compileOnly 'org.projectlombok:lombok:1.18.6' <--追加
    annotationProcessor 'org.projectlombok:lombok:1.18.6' <--追加
}

エラー 1

Warning:<i><b>root project 'complete': Unable to resolve additional project configuration.</b>
Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':runtimeClasspath'.
Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could not download spring-boot-starter-web.jar (org.springframework.boot:spring-boot-starter-web:2.1.3.RELEASE): No cached version available for offline mode</i>

対策 1

どの対策が聞いたかわかりませんが、上から順にやって最後に成功しました。

  1. Enable annotation processingにチェックを入れる。
    Intellij IDEA -> Preferences -> Compiler -> Annotation Processors
    スクリーンショット 2019-04-05 17.46.29.png

  2. Enable annotation processingにチェックを入れる。
    File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors
    スクリーンショット 2019-04-08 11.02.20.png
    スクリーンショット 2019-04-08 11.02.56.png

  3. Lombokプラグインをインストール
    Intellij IDEA -> Preferences -> Plugins ->Browse Repositories-> Search for "Lombok"-> install plugin -> Apply and restart IDEA
    スクリーンショット 2019-04-08 11.04.35.png

  4. Work offlineにチェックを入れる。
    Intellij IDEA -> Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle
    スクリーンショット 2019-04-05 17.44.53.png

エラー 2

上記の対策後、ビルド実行すると下記のエラーが出ました。

スクリーンショット 2019-04-08 10.55.32.png

対策 2

pom.xmlに下記を追加しました。
参考: https://tyoshikawa1106.hatenablog.com/entry/2015/11/15/220056


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- ここから -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.6</version>
            <scope>provided</scope>
        </dependency>
        <!-- ここまで追加 -->
    </dependencies>

無事ビルドが通りました。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0