How to create your first Mule Maven application

Home > Search > How-to
  by

If Maven is not installed, download Maven from https://maven.apache.org/download.cgi. Let's say apache-maven-3.5.0-bin.tar.gz is downloaded to /home/john.doe/Downloads. Use tar to extract the downloaded package.

[john.doe@server1 ~]# tar -zxvf /home/john.doe/Downloads/apache-maven-3.5.0-bin.tar.gz -C /etc/maven

If using the Community Edition of Mule, add the Anypoint Studio Communitiy Runtimes

  1. In Mule, select Help > Install New Software.
  2. Select Mule Runtimes for Anypoint Studio, check Anypoint Studio Community Runtimes, and select Next.
  3. Select Next.
  4. Select Finish.
  5. Restart Mule.

 

Configure Mule to use Maven

  1. In Mule, select Window > Preferences.
  2. In the left panel, expand Anypoint Studio and select Maven.
  3. Select Browse, navigate to /etc/maven/apache-maven-3.5.0 and select OK.
  4. Select Test Maven Configuration, and ensure a green check mark is displayed.
  5. Select Apply.
  6. Select OK.

 


Create a Maven project

  1. In AnyPoint Studio, select File > New > Mule Project.
  2. Give the project a name, such as MyMavenProject, check Use Maven, and select Finish.

Note: If using a Community Editon version of Mule, ensure you select one of the CE (Community Editon) Runtimes.

  1. Drag the HTTP connector to the canvas.
  2. Search for Set Payload, and drag Set Payload into the canvas, so that the HTTP connector connects to the Set Payload connector.

 

  1. Hightlight the HTTP connector. Under HTTP, click the green plus icon and select OK. Connector Configuration should now display HTTP_Listener_Configuration.
  2. Select Path to *.

 

  1. Select the Set Payload connector, and set value to Hello Maven.

 

  1. Select the HTTP connector.
  2. In the top menu, select Run > Run As > Mule Application with Maven and select OK. The Console should display the name of your project and a status of DEPLOYED.

 

  1. Navigate to http://localhost:8081, and Hello World should be displayed.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments