How to use "-Amapstruct.defaultComponentModel=spring" in POM

2,087 views
Skip to first unread message

sheka...@gmail.com

unread,
Feb 17, 2017, 4:46:58 AM2/17/17
to mapstruct-users
Hi,

I have used @Mapper(componentModel = "spring") to inject mapper object in my application and successfully mapped my DTO to entities.But when i was trying to configure through cofiguration options instead of using @Mapper(componentModel = "spring") getting exception as "invalid flag : -Amapstruct.defaultComponentModel=spring".

Could you please let me know if i was passing wrong processor option.

Thanks. 

Andreas Gudian

unread,
Feb 17, 2017, 2:23:33 PM2/17/17
to sheka...@gmail.com, mapstruct-users
Hi Shekar,

that highy depends on how you are configuring the annotation-processing in the pom and where in the configuration you've added the parameter.

But based on the error message, I'd say that you just have to remove the "-A" prefix in your case.

If that doesn't do the trick, please give us a snippet of the related plugin configuration in your pom.

Andreas

--
You received this message because you are subscribed to the Google Groups "mapstruct-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapstruct-users+unsubscribe@googlegroups.com.
To post to this group, send email to mapstruct-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gunnar Morling

unread,
Feb 17, 2017, 2:43:25 PM2/17/17
to sheka...@gmail.com, Andreas Gudian, mapstruct-users
That said, I'd rather recommend you use a @MapperConfig class [1] for
configuring the component model in a single place.

In hindsight, that processor option should not have been added and it
may be a candidate for removal in a future version.

--Gunnar

[1] http://mapstruct.org/documentation/stable/reference/html/#shared-configurations


2017-02-17 20:23 GMT+01:00 Andreas Gudian <andreas...@gmail.com>:
> Hi Shekar,
>
> that highy depends on how you are configuring the annotation-processing in
> the pom and where in the configuration you've added the parameter.
>
> But based on the error message, I'd say that you just have to remove the
> "-A" prefix in your case.
>
> If that doesn't do the trick, please give us a snippet of the related plugin
> configuration in your pom.
>
> Andreas
>
> 2017-02-17 10:46 GMT+01:00 <sheka...@gmail.com>:
>>
>> Hi,
>>
>> I have used @Mapper(componentModel = "spring") to inject mapper object in
>> my application and successfully mapped my DTO to entities.But when i was
>> trying to configure through cofiguration options instead of using
>> @Mapper(componentModel = "spring") getting exception as "invalid flag :
>> -Amapstruct.defaultComponentModel=spring".
>>
>> Could you please let me know if i was passing wrong processor option.
>>
>> Thanks.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "mapstruct-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to mapstruct-use...@googlegroups.com.
>> To post to this group, send email to mapstru...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "mapstruct-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mapstruct-use...@googlegroups.com.
> To post to this group, send email to mapstru...@googlegroups.com.

sheka...@gmail.com

unread,
Feb 20, 2017, 2:26:50 AM2/20/17
to mapstruct-users, sheka...@gmail.com

Thank you Andreas, as you suggested i have tried by removing "-A" prefix but still getting same error.Below is the snippet of plugin configuration.

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
  <target>1.8</target>
  <annotationProcessorPaths>
  <path>
  <groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.1.0.Final</version>
  </path>
  </annotationProcessorPaths>
                        <compilerArgs>
  <compilerArg>
  -Amapstruct.defaultComponentModel=spring
  </compilerArg>  
  </compilerArgs>
  </configuration>
</plugin>
</plugins>
</build>

Thanks,
Shekar.

On Saturday, February 18, 2017 at 12:53:33 AM UTC+5:30, Andreas Gudian wrote:
Hi Shekar,

that highy depends on how you are configuring the annotation-processing in the pom and where in the configuration you've added the parameter.

But based on the error message, I'd say that you just have to remove the "-A" prefix in your case.

If that doesn't do the trick, please give us a snippet of the related plugin configuration in your pom.

Andreas
2017-02-17 10:46 GMT+01:00 <sheka...@gmail.com>:
Hi,

I have used @Mapper(componentModel = "spring") to inject mapper object in my application and successfully mapped my DTO to entities.But when i was trying to configure through cofiguration options instead of using @Mapper(componentModel = "spring") getting exception as "invalid flag : -Amapstruct.defaultComponentModel=spring".

Could you please let me know if i was passing wrong processor option.

Thanks. 

--
You received this message because you are subscribed to the Google Groups "mapstruct-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapstruct-use...@googlegroups.com.
To post to this group, send email to mapstru...@googlegroups.com.

sheka...@gmail.com

unread,
Feb 20, 2017, 2:27:47 AM2/20/17
to mapstruct-users, sheka...@gmail.com, andreas...@gmail.com

Thank you Gunnar.

Thanks,
Chandra shekar.G

Andreas Gudian

unread,
Feb 21, 2017, 2:49:37 PM2/21/17
to sheka...@gmail.com, mapstruct-users
Shekar,

I just tried it out myself and for me it's working. What JDK do you use? If it's a more or less up-to-date Oracle JDK 1.8 version, and this blocks you from anything, then we'd need a small sample project to reproduce and dig in further.

What Gunnar said is true, though - configuring the component model should be done using the annotations, and if that's not too much hassle for you our recommendation would be to use the @MapperConfig for this particular setting -- we didn't have the @MapperConfig annotation back when the component models were introduced, I think... :)

Andreas
Reply all
Reply to author
Forward
0 new messages