Skip to main content
dnelson42
Level 2
Oct 16, 2015 2:28 AM UTC
Solved

Sling Models in AEM 5.6.1?

I recently read a great article on apache sling models and I thought I would try to put it to use in AEM 5.6.1 but I am having trouble getting the dependecies and maven-bundle-plugin settings just right. Has anyone else tried this with success?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
JustinEd3Accepted solution
Adobe Employee
Oct 16, 2015 2:28 AM UTC

Hi,

The fastest way to get started with Sling Models on 5.6.1 is to download the package from https://github.com/Adobe-Consulting-Services/com.adobe.acs.bundles.sling-models/releases/tag/com.adobe.acs.bundles.sling-models-1.0.2 and install it in your AEM instance. This will give you the two bundles you need at runtime.

Then, in your bundle project, you need to do two things (aside from actually creating the model classes/interfaces):

1. Add this dependency:

<dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.models.api</artifactId> <version>1.0.0</version> <scope>provided</scope> </dependency>

2. In the <configuration> element inside the plugin definition for the maven-bundle-plugin add this:

<instructions> <Sling-Model-Packages> com.myco.mypackage </Sling-Model-Packages> </instructions>

Note that you might already have an <instructions> element, in which case just add <Sling-Model-Packages> inside that existing <instructions> element.

If this doesn't solve your problem, please post more details on exactly what is going wrong.

Regards,

Justin

2 replies

Oct 16, 2015 2:28 AM UTC

dnelson42 wrote...

I recently read a great article on apache sling models and I thought I would try to put it to use in AEM 5.6.1 but I am having trouble getting the dependecies and maven-bundle-plugin settings just right. Has anyone else tried this with success?

 


Care to share the article URL?

This is an area that I am currently considering. I am aware of this link :-

http://sling.apache.org/documentation/bundles/models.html

and have also been reading about Cognifide's 'Slice' implementation :-

http://www.cognifide.com/blogs/cq/make-your-cq-life-easier-with-slice/

Regards

Fraser

Translate
JustinEd3Adobe EmployeeAccepted solution
Adobe Employee
Oct 16, 2015 2:28 AM UTC

Hi,

The fastest way to get started with Sling Models on 5.6.1 is to download the package from https://github.com/Adobe-Consulting-Services/com.adobe.acs.bundles.sling-models/releases/tag/com.adobe.acs.bundles.sling-models-1.0.2 and install it in your AEM instance. This will give you the two bundles you need at runtime.

Then, in your bundle project, you need to do two things (aside from actually creating the model classes/interfaces):

1. Add this dependency:

<dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.models.api</artifactId> <version>1.0.0</version> <scope>provided</scope> </dependency>

2. In the <configuration> element inside the plugin definition for the maven-bundle-plugin add this:

<instructions> <Sling-Model-Packages> com.myco.mypackage </Sling-Model-Packages> </instructions>

Note that you might already have an <instructions> element, in which case just add <Sling-Model-Packages> inside that existing <instructions> element.

If this doesn't solve your problem, please post more details on exactly what is going wrong.

Regards,

Justin

Translate