Expand my Community achievements bar.

SOLVED

Sling Models in AEM 5.6.1?

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Employee

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.ado... 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

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

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.ado... 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

Avatar

Former Community Member

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