Level 2
June 1, 2016
Solved
Sling Model API update to v1.2.2 (AEM 6.2) Not support @Inject anymore
- June 1, 2016
- 5 replies
- 2228 views
AEM 6.2 uses Sling Model API 1.2.2, but this bundle seems not include @Inject annotation. So how to I inject some of sightly object inside Sling Model?
Old version look like:
@Model(adaptables = Resource.class) public class HelloWorldModel { @Inject private SlingSettingsService settings; @Inject @Named("sling:resourceType") @Default(values = "No resourceType") protected String resourceType; private String message; @PostConstruct protected void init() { message = "\tHello World!\n"; message += "\tThis is instance: " + settings.getSlingId() + "\n"; message += "\tResource type is: " + resourceType + "\n"; } public String getMessage() { return message; } }Up to new sling model 1.2.2, the @Inject doesnt work anymore.
Please help.