Adobe Experience Manager (AEM) Maven project for SPA React application

Adobe Experience Manager (AEM) Maven project for SPA React application

Couple of days back, I was trying to create a project for Adobe Experience Manager (AEM) Maven project as a starting point for my React application. To do this I was using the documentation provided by Adobe. Trust me, it took me some time to create the project for my SPA application using react. I am sharing my experience and what I did to solve the problems I faced.

Please refer following Adobe url for reference. https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-with-aem-headless/spa-editor/react/create-project.html?lang=en

I am going to use the same project name and details used in the Adobe document for simplicity. based on your need, you can update the details in Maven archetype is provided in the adobe document and also you see down for the Maven archetype.

Prerequisites (Required software)

I will not go into the details of installation. You will find tons of reference document on internet. But drop me a note in case of issue I will certainly try to help. Let now go through the steps for creating a maven archetype project for react SPA application.

Step 1: update the following pom file before running the archetype "C:\Users\Ananya\.m2\repository\org\apache\maven\archetype\archetype-common\3.2.1\archetype-common-3.2.1.pom." update the version from “2.4.16” to 2.4.8”

<dependency
?????<groupId>org.codehaus.groovy</groupId>
?????<artifactId>groovy-all</artifactId>
?????<version>2.4.8</version>
?????<scope>compile</scope>
???</dependency>        

Step 2: Open up a command line terminal (in Administrator mode) and enter the following Maven command:

mvn -B archetype:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=27 -D appTitle="WKND SPA React" -D appId="wknd-spa-react" -D artifactId="aem-guides-wknd-spa.react" -D groupId="com.adobe.aem.guides.wkndspa.react" -D frontendModule="react" -D aemVersion="6.5.5"        

Step 3: You will see that Project is created with error. You will see error something similar to given below:

“error reading .m2\repository\com\adobe\aem\uber-jar\6.5.5\uber-jar-6.5.5.jar; error in opening zip file.”        

Step 4: To fix this issue, go to path “projectPath\reactExample\aem-guides-wknd-spa.react\pom.xml” and update pom.xml file for uber-jer to version 6.5.8. By default you will see version 6.5.5. Following is the updated dependency.

<dependency
????<groupId>com.adobe.aem</groupId>
????<artifactId>uber-jar</artifactId>
????<version>6.5.8</version>
????<scope>provided</scope>
</dependency>         

Note: “reactExample” is the folder where I am creating the project. Please check path in your case.

Step 4: Move inside the SPA project folder (“aem-guides-wknd-spa.react”) in my case and run the following command from CMD (start your CMD in admin mode).

No alt text provided for this image


Step 5: wait for this complete. This “mvn clean install” takes around 10 mins to complete depending upon your internet speed. You will see following after successful build.

No alt text provided for this image





Step 6: Final step is to Run the following command to build and deploy the entire project to your AEM instance:

No alt text provided for this image


That’s it. You will see package deployed to your AEM instance.

Let me know in case of any doubt. Happy Learning!


Behnaz Bagherian

Web Application Developer | Java Developer | AEM Developer (Apache Sling/ OSGI/ CRX) | Spring Boot | MVC | RESTful API

1 å¹´

Hi Sandip, thanks for the article. however I am getting error on maven-frontend plugin, stating that it can't download node.js. any idea on this?

赞
回复
Veena Karnick

Lead Consultant at ITC Infotech India Ltd

2 å¹´

Hi Sandip, Ur article helped me alot ...i was trying to integrate simple AEM components following the experienceLeague page. After successful build for integration i see the home page is either Blank or my components cant be seen integrated on the page. Browser indicates CORS error. Access to XMLHttpRequest at 'https://api.ciuvo.com/api/analyze?url=http%3A%2F%2Flocalhost%3A4502%2F&version=2.1.3&tag=threesixty&uuid=CF5B7BF1-2FBD-46FC-AA34-339A339D2DA0' from origin 'https://localhost:4502' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

赞
回复

要查看或添加评论,请登录

Sandip kumar的更多文章

  • Exploring AEM Deployment Options: On-Premise, Managed Service, and Cloud Service

    Exploring AEM Deployment Options: On-Premise, Managed Service, and Cloud Service

    Contents Objective Introduction Technical Factors for AEM Deployment Differences On-Premises vs. Managed vs.

    3 条评论
  • Contentful...Headless CMS & AEM

    Contentful...Headless CMS & AEM

    The traditional CMS approach to managing content puts everything into one big bucket — content, images, HTML, CSS, you…

  • iParsys (inherited paragraph system) & Inheritance

    iParsys (inherited paragraph system) & Inheritance

    In the older version CQ/AEM, the inheritance in AEM works through iParsys. To understand iParsys, 1st we need to…

  • Code generator in AEM with Sling Models & Lombok

    Code generator in AEM with Sling Models & Lombok

    Have you ever though about using code generators in AEM. Code generators save us from having to write monotonous Java…

  • Unit Tests With Springboot

    Unit Tests With Springboot

    Just had a change to work with my development team to define a process for developing unit tests for a…

    2 条评论

社区洞察

其他会员也浏览了