I have created a new component and when i try to use the sling model using data-sly-use
i get the below error , is there any reason for this error?
org.apache.sling.scripting.sightly.SightlyException: Compilation errors in org/apache/sling/scripting/sightly/apps/myproject/components/content/components/demo__component/demo__002d__component__002e__html.java: Line 39, column 1932 : com.myproject.core.slingmodels.components.democomponent.DemoComponentModel cannot be resolved to a type
This is my sling model
package com.myproject.core.slingmodels.components.democomponent;
import com.myproject.core.slingmodels.HeaderModel;
import lombok.Getter;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.ChildResource;
@Getter
@Model(adaptables = Resource.class,
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class DemoComponentModel {
@ChildResource
private HeaderModel Heading;
}
Solved! Go to Solution.
Views
Replies
Total Likes
Can you check if the package info file has been added - this will scan the models
@Version("1.0") package com.your.sling.models.yourpackage; import org.osgi.annotation.versioning.Version;
Views
Replies
Total Likes
Hi @Zendark ,
You may check status of bundle http://localhost:4502/system/console/bundles
@Getter can be filed level or use @Data annotation for class level as mentioned below
https://kiransg.com/tag/getter/
You may check here how to use lambok https://experienceleaguecommunities.adobe.com/t5/experience-league-showcase-2022/using-project-lombo...
If issue doesn't resolved you may have a look https://github.com/adobe/aem-project-archetype/issues/221 as your are using sub folder
Thanks
Views
Replies
Total Likes
You need to check more entry in logs. It’s actually failing during compilation so it seems it has something to do with your code abd log will give you more insights on this.
What about this class ? Have you defined it properly?
HeaderModel
Views
Replies
Total Likes
Hi @Zendark
Can you please check if you are adding the sling models package in pom as well
<Sling-Model-Packages>com.myproject.core.slingmodels</Sling-Model-Packages>
Views
Replies
Total Likes
Can you check if the package info file has been added - this will scan the models
@Version("1.0") package com.your.sling.models.yourpackage; import org.osgi.annotation.versioning.Version;
Views
Replies
Total Likes
By adddind this file in my sling model folder , it works thank you
Views
Likes
Replies
Views
Likes
Replies