eclipse使用mapstruct_如何将MapStruct与Eclipse正确集成? (包括Lombok Java代理)

I'm willing to use MapStruct in some official project so I decided to give it some testing first; I'd need to make it work integrated with eclipse and followed all the instructions provided on MapStruct website but ... so far no luck. Did anyone succeeded on such integration? and if yes what can I be missing?

My test started with something bigger, but when I realized it was not working I decided to use a smaller example, so this is what I did:

Using openjdk-10.0.1_windows-x64

downloaded and installed a fresh version of eclipse

(eclipse-jee-2019-03-R-win32-x86_64)

installed latest m2e-apt (and mapstruct plugin though not needed for

this exercise) as suggested in

http://mapstruct.org/documentation/ide-support/

imported from git (from within eclipse) mapstruct-clone project

(looked the basic-est example)

checked the settings as suggested in

http://mapstruct.org/documentation/dev/reference/html/ (chap 2.1) and

everything looks good

... no way to persuade eclipse to auto-generate the mapper implementation, I even added the jdt_apt line to the pom.

Here is a snippet of the pom.xml - please refer to he mapstruct-clone project for the whole code.

1.3.0.Final

jdt_apt

Expected result would be:

to find my re-generated classes under

"target/generated-sources/annotations" when I save a mapping

interface

(as stated by http://mapstruct.org/documentation/dev/reference/html/

" it will set up the MapStruct annotation processor so it runs right

in the IDE, whenever you save a mapper type. Neat, isn’t it?")

but do not

I can only get the classes generated through a "mvn clean install"

which is good but not that handy

Important edit: I'm also using the lombok javaagent

解决方案

I eventually found the solution to the issue ( =D )

first thanks to Sjaak Derksen from MapStruct team for supporting me

second thanks to Pavel Horal for posting this solution

https://github.com/mapstruct/mapstruct/issues/1159

and finally thanks to myself for being so stubborn (well sometimes it

helps)

The issue was indeed tied to an incompatibility between Lombok java agent and MapStruct.

To get it to work just do what Pavel suggested in his last post and it will work:

[...] simply remove the SPI registration inside lombok.jar (by deleting META-INF/services/org.mapstruct.ap.spi.AstModifyingAnnotationProcessor) [...]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值