Getting started Community Training Tutorials Documentation APIs, AI & Tools
http://www.mulesoft.org/schema/mule/spring
http://www.mulesoft.org/schema/mule/spring/current/mule-spring.xsd
Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio.
If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven pom.xml file.
When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the pom.xml file.
Paste the following code inside the <mule> tag of the header of your configuration XML:
http://www.mulesoft.org/schema/mule/spring
http://www.mulesoft.org/schema/mule/spring/current/mule-spring.xsd
This example shows how the namespace statements are placed in the <mule> XML block:
<mule xmlns:spring="http://www.mulesoft.org/schema/mule/spring"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
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/file
http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/spring
http://www.mulesoft.org/schema/mule/spring/current/mule-spring.xsd">
The Apache Maven pom.xml file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your pom.xml file to enable access to this connector:
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-spring-module</artifactId>
<version>x.x.x</version>
<classifier>mule-plugin</classifier>
</dependency>
Replace x.x.x with the version that corresponds to the connector you are using.
To obtain the most up-to-date pom.xml file information:
Go to Anypoint Exchange.
In Exchange, click Login and supply your Anypoint Platform username and password.
In Exchange, search for spring module.
Select the connector.
Click Dependency Snippets near the upper right of the screen.
Spring Module 2.2.0 and later defines the required Spring libraries at the configuration level. When you create a spring:v7-config configuration, Anypoint Studio and Anypoint Code Builder can display Spring 6 libraries (spring-beans, spring-context, and spring-core) as loaded. In Studio, selecting Remove configured library has no effect, and in Anypoint Code Builder, the required libraries parameter isn’t displayed. Don’t rely on the libraries shown in the configuration screen.
To use Spring 7, manually edit the pom.xml file of your project. These steps apply to both Anypoint Studio and Anypoint Code Builder.
Add the Spring libraries as shared libraries in the configuration element of the mule-maven-plugin:
<configuration>
<sharedLibraries>
<sharedLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-access</artifactId>
</sharedLibrary>
</sharedLibraries>
</configuration>
Add the Spring 7 libraries as dependencies in the dependencies element:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>7.0.9</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>7.0.9</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>7.0.9</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>7.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>7.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>7.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-access</artifactId>
<version>7.1.1</version>
</dependency>
These are the library versions:
Spring Framework (spring-beans, spring-context, and spring-core): 7.0.9
Spring Security (spring-security-config, spring-security-crypto, spring-security-core, and spring-security-access): 7.1.1
You must list each library as both a dependency and a shared library. The spring-security-access library is optional. Add it only if your app uses the legacy access API classes that Spring Security 7 moved to this library.