MapStruct and Lombok not working together

前端 未结 5 901
陌清茗
陌清茗 2020-11-28 05:05

Tech Stack being used :

Java 8 MapStruct : 1.2.0.Final Lombok: 1.16.18 IDE: IntelliJ - Lombok Plugin already installed

  • Initially, I faced issues when
5条回答
  •  难免孤独
    2020-11-28 05:56

    For me solution was realy simple.

    The order of the processors was important.

    In my case mapstruct processor was defined before lombok processor. In case with bad order mapstruct does not generate mappings, just create instance of result class (i saw that in generated implementation).

    My plugin configuration with right order:

    
        org.apache.maven.plugins
        maven-compiler-plugin
        ${maven.compiler.plugin.version}
        
            15
            15
            --enable-preview
            
                
                    org.projectlombok
                    lombok
                    ${lombok.version}
                
                
                    org.mapstruct
                    mapstruct-processor
                    ${mapstruct.version}
                
            
        
    
    

    And of course you need to add dependencies:

    
        
            org.projectlombok
            lombok
            provided
        
        
            org.mapstruct
            mapstruct
            ${mapstruct.version}
        
    
    

提交回复
热议问题