Contact Free trial Login

Building a Mule Application with Maven outside Studio

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.

This guide walks you through creating a Mule Application project from scratch using a Maven archetype. It covers generating a project template, revising the configuration to create a simple "Hello World" application, manually maintaining its POM file, then building and deploying the project.


The document assumes you have downloaded Apache Maven and are familiar with using it to build and maintain projects. Read more about Using Maven with Mule.

Configuring Maven

Add the two blocks of code to the file settings.xml (usually in your Maven conf or $HOME/.m2 directory)

This will have Maven allow you to execute Mule plugins:



This will tell your Maven instance where to find the Mule repositories:


    <id>Mule Org</id>
            <name>MuleSoft Repository</name>
            <name>MuleSoft Snapshot Repository</name>
If you need to add dependencies that are not included (for example to the Salesforce connector), or if you’re using Mule Enterprise and need the enterprise repositories, see Configuring Maven POM Files and Settings.

Creating a Project Template

  1. Open a command shell and navigate to the directory where you want to create your project.

  2. Execute the mule-project-archetype as shown. If this is your first time running this command, Maven downloads the archetype for you.

    mvn mule-project-archetype:create -DartifactId=helloWorld -DmuleVersion=3.5.0

    Running the archetype

    Maven uses by default the latest available version of the archetype. This can cause problems if you want to create a project for an earlier version of Mule. In this case, run the mule-project-archetype specifying the full version of the plugin like this:

    mvn ...

    At minimum, you pass in two system parameters:

    • artifactId: The short name for the project (such as myApp). This should be a single word in lower camel case with no spaces, periods, hyphens, etc.


      The artifactId can contain characters such as underscore or hyphen. However, the plug-in will convert the name into a usable form suitable for Java. For example, if the argument is specified as -DartifactId=My#Awesome-Mule_Project, the project will be created in a directory of that name, but the project name will be MyAwesomeMuleProject and the package name will be .myawesomemuleproject
    • muleVersion: The version of the Mule project archetype you want to use. This will also be the default Mule version used for the generated artifact.

  3. The plugin asks a series of questions. The table below shows a set of possible responses.

    Question Answer

    Provide a description of what the project does.

    This is a basic "Hello, World" test project.

    Which version of Mule is this project targeted at?


    What is the base Java package path for this project?


    Which Mule transports do you want to include in this project?


    Which Mule modules to you want to include in this project?

    (Leave blank.)

    You can also choose to run this archetype in "silent mode" by including -DinteractiveMode=false, then passing in any of the following parameters.

    Name Example Default Value

















    -Ddescription="My Hello World app"







    <current dir>










  4. After you have answered all the questions, the archetype creates a directory using the project name you specified. This directory includes:

    1. a POM file for building with Maven

    2. a Mule configuration file ( src\main\app\mule-config.xml ) that includes the namespaces for the transports and modules you specified and has placeholder elements for creating your first flow

    3. a package.html file under src\main\java using the package path you specified, i.e. src\main\java\com\mycompany\project\package.html

    4. some template files under src\test to help you get started creating a unit test for the project

    5. A new MULE-README.txt file in the root of your project, explaining what files were created

Creating a Mule Application from the Template

  1. Open src/main/app/mule-config.xml. Delete the flow that exists by default and add this one:

    <flow name="exampleFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost"
    port="8081" />
        <set-payload value="Hello World!"/>
  2. Save this mule-config.xml. You now have a working project that can be packaged and deployed.

Managing Dependencies

If you add logic into your project that relies on a dependency that isn’t already included in the POM file generated by the archetype, you have to modify your POM file manually to add this dependency, as described here. This example walks you through revising your project test case in a way that requires an additional Maven dependency: the REST-assured DSL .

  1. Open the example test case file, src/test/java/com/mycompany/project/helloWorld/ and replace the existing code with the following:

    package com.mycompany.project.helloworld;
    import static org.junit.Assert.*;
    import static com.jayway.restassured.RestAssured.*;
    import org.junit.Test;
    import org.mule.tck.junit4.FunctionalTestCase;
    import org.apache.commons.cli.ParseException;
    public class HelloWorldTestCase extends FunctionalTestCase {
        private static String MESSAGE = "Hello world!";
        protected String getConfigResources()
        return "mule-config.xml";
        public void dependencyClientTestCase() throws Exception
        String response = get("http://localhost:8081").body().asString();
        assertEquals(MESSAGE, response);

    * Line 4: Imports REST-assured
    * Lines 21-22: use REST-assured

  2. Add the following dependencies to your pom.xml file, located in the application’s root folder.

  3. While in the directory where the pom.xml file resides, package your Mule project from the command line by executing the following syntax:

    mvn package

    The maven-mule-plugin packages the project in a . zip file. Copy the .zip file to the apps folder of your standalone Mule ESB instance to run the application.

  4. The console should print BUILD SUCCESS.


See Also

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub