While reading AEM documentation about using models, I couldn't figure out what is the difference between @Inject and @ValueMapValue annotation above the field.
I tried using both, and they both seems the same, so I must be missing something.
They are not the same, @Inject
is a general purpose annotation that makes the value available from a number of injectors.
@ValueMapValue
is an injector specific annotation that will specifically pick value from valuemap injector. It is equivalent to @Inject @Source("valuemap")
When the injected value is available only from one injector, their behavior would be the same, however if the same property is provided by two different injectors (say script-binding and valuemap) they might inject different values. Read more here.