天天看點

MapStruct - Ambiguous constructors found

Ambiguous constructors found for creating com.app.test.UserInfo. Either declare parameterless 

constructor or annotate the default constructor with an annotation named @Default.

方法一、手動添加顯示構造無參方法

方法二、添加 @Default 注解

package foo.support.mapstruct;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.CONSTRUCTOR)
@Retention(RetentionPolicy.CLASS)
public @interface Default {
}      
@Default
public UserInfo(String username, String area) {
    //...
}      

繼續閱讀