Over a million developers have joined DZone.

Running Mule CE Embedded in Spring Boot

DZone's Guide to

Running Mule CE Embedded in Spring Boot

In this post, a Mule developer gives a quick tutorial on how to integrate Spring Boot with into your Mule project using the open source Mule CE tool.

· Integration Zone ·
Free Resource

Discover how you can get APIs and microservices to work at true enterprise scale.

Mule CE is an open source integration tool. Mule CE applications are normally run inside a Mule runtime. With mule-spring-boot-starter, you can run Mule CE embedded in a Spring Boot application. This allows Mule developers to quickly prototype and/or deploy Mule applications without having to download Mule runtime, create a Maven artifact, and push the artifact to the Mule runtime. This project will allow developers to build and run the Mule application in much the same manner as other Spring Boot applications.

Add Maven Dependency:


Add Repositories:

        <name>MuleSoft Repository</name>
        <name>MuleSoft Snapshot Repository</name>
        <name>Spring Milestones Repository</name>

Add Mule Modules and Dependencies as Needed:

In the demo application, the HTTP connector is used so that a jar file is needed for the XML schema and corresponding Java code to support the HTTP connector.


Create a Mule Config File:

Make sure this file is in the artifact classpath. Create an application property called
 mule.config.files. Add a comma separated list of mule config files.


Here's an example mule-config.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="" port="8081" doc:name="HTTP Listener Configuration" />
    <flow name="mule-demo-filesFlow">
        <logger level="INFO" doc:name="Logger" category="net.taptech" message="It works!!!!" />
        <set-payload value="testing" doc:name="Set Payload" />
    <flow name="mule-demo-filesFlow1">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP" />
        <flow-ref name="mule-demo-filesFlow" doc:name="mule-demo-filesFlow" />

Add Annotation to Your Spring Boot Application Entry Point:


public class DemoMuleSpringBootApplication {

 private static final Logger logger = LoggerFactory.getLogger(DemoMuleSpringBootApplication.class);

 private ApplicationContext context;

 public static void main(String...args) {
  logger.info("Starting SpringApplication...");
  SpringApplication app = new SpringApplication(DemoMuleSpringBootApplication.class);
  logger.info("SpringApplication has started...");

You can now run your application:

./mvnw clean package -Dmaven.test.skip=false && java -jar target/demo-mule-spring-boot-0.0.1-SNAPSHOT.jar

The demo project can be viewed on my GitHub

APIs and microservices are maturing, quickly. Learn what it takes to manage modern APIs and microservices at enterprise scale.

mule ,integration ,spring boot

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}