Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Dependencies needed to inject Content Aware Configuration annotation @ContextAwareConfiguration

Avatar

Level 5

I am trying to use @ContextAwareConfiguration to inject CA config into Sling models. This annotation is not resolved even after adding the dependency in my core pom.xml

<dependency>
    <groupId>org.apache.sling</groupId>
    <artifactId>org.apache.sling.models.caconfig</artifactId>
    <version>1.0.2</version>
</dependency>

It would be helpful if someone could share the correct dependency details

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
7 Replies

Avatar

Community Advisor

Hi @narendiran_ravi ,

As per doc https://sling.apache.org/documentation/bundles/models.html

It is available from 1.0.0 and I am able to resolve in both

MukeshYadav__0-1722528036571.png

can you explicitly import  in your code

import org.apache.sling.models.caconfig.annotations.ContextAwareConfiguration;

MukeshYadav__0-1722528177209.png

 

Thanks

 

Avatar

Level 5

Thanks @MukeshYadav_  for the reply. I tried to add the import directly in the model file but it is not resolved. I am not sure what I am missing.

 

narendiran100_0-1722528888914.png

 

Under which pom.xml file you have included the dependency and what is the dependency you have added? Could you please share your pom.xml if possible? 

myproj.core:1.0.0-SNAPSHOT is importing package(s) org.apache.sling.models.caconfig.annotations in start level 20 but no bundle is exporting these for that start level. (com.test:myproj.all:1.0.0-SNAPSHOT)  - Compilation issue is resolved in core module, but getting this error in all module 

Avatar

Correct answer by
Community Advisor

Avatar

Level 5

This method we are already using I am trying to use annotation based injection

Avatar

Level 5

After embedding the dependency in all pom it is working. This bundle is not provided by AEM SDK. So we need to explicitly embed in all pom so that it will be included in the build.