2017-12-14 14 views
0

を解決することはできません私はスーパーロンボク+のIntelliJは:スーパークラスのメソッド

@Data 
@AllArgsConstructor 
@NoArgsConstructor 
@Builder 
public class ErrorResponse { 
    @JsonProperty 
    private String message; 
} 

を持っていると私はこの

ようなオブジェクトを作成するためのビルダーを使用する場合、私は1

@Data 
@NoArgsConstructor 
@AllArgsConstructor 
@Builder(builderMethodName = "_builder") // add custom builder name to avoid compilation issue 'return type is not compatible...' 
@EqualsAndHashCode(callSuper=true) 
public class AskQuestionErrorResponse extends ErrorResponse { 
    @JsonProperty 
    private String status; 

    @Builder(builderMethodName = "_builder") // add custom builder name to avoid compilation issue 'return type is not compatible...' 
    private AskQuestionErrorResponse(String status, String message){ 
     super(message); 
     this.status = status; 
    } 
} 

子供を持っています

AskQuestionErrorResponse._builder() 
    .status(1) 
    .message("my message here").build() 

Intellijが私にmessageと表示され、問題が発生しました。cannot resolve method 'message(java.lang.String)'とにかくプロジェクトコンパイルこのエラーでも実行されます。

私はすでに歳差運動を行っています。

私はこの

AskQuestionErrorResponse._builder() 
       .status(ex.getStatus().getValue() 
       //.message(ex.getMessage() 
       ).build() 

のようなスーパークラスからフィールドをコメントする場合、それは動作します。それはスーパークラスのメンバーが表示されないようです。私もmavenをきれいにしてインストールして、プロジェクトを再構築しようとしました。

UPDATE ロンボクプラグインがインストールされている enter image description here

注釈プロセッサがPreferencesに有効とDefault preferences

enter image description here

enter image description here

答えて

0

私はそれを見つけました。私のクラスを見てみると、2つの@Builder注釈が表示されます。私は最初のものを削除し、魔法が起こります。今、私のクラスは次のようになりますと警告

@Data 
@NoArgsConstructor 
@AllArgsConstructor 
@EqualsAndHashCode(callSuper=true) 
public class AskQuestionErrorResponse extends ErrorResponse { 
    @JsonProperty 
    private String status; 

    @Builder(builderMethodName = "_builder") // add custom builder name to avoid compilation issue 'return type is not compatible...' 
    public AskQuestionErrorResponse(String status, String message){ 
     super(message); 
     this.status = status; 
    } 
} 

はありません、それはそれは、すでにインストールされます:)

0

にあなたはそれようのIntelliJロンボクプラグインをインストールする必要がありますされていますcompiの前に注釈を理解することができますバイトコードへの変換。 https://projectlombok.org/setup/intellij

+0

お役に立てば幸いです。 'AskQuestionErrorResponse._builder()。status(ex.getStatus()。getValue())。スーパークラスのフィールドを持たないbuild()'が完全に動作する – Vitalii

+0

https://stackoverflow.com/questions/に役立ついくつかの追加情報があります。 24006937/lombok-annotations-do-not-compile-under-intellij-idea?rq = 1 – Mark

+1

@Builderアノテーションに問題があるようです。可能な(しかし完全ではない)回避策については、https://reinhard.codes/2015/09/16/lomboks-builder-annotation-and-inheritance/で説明します。 – Mark

関連する問題