---
schema_version: "1"
id: 1575f40a4ce311aa7fb4f0c7965f34aaebcda4874d615ff57c7c91b3e7a1bc26
title: Spring Module XML and Maven Support
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/spring-module/latest/spring-xml-maven.md
canonical_url: https://docs.mulesoft.com/spring-module/latest/spring-xml-maven
source_site: docs.mulesoft.com
content_type: documentation
content_hash: c829401f43002d9d9da87e4ea2404a87392eac740ee9b6997f8529efc9ca38a1
description: MuleSoft Documentation Site
release: "2.2"
latest: true
---
---
product: Spring Module
version: 2.2
is-latest-version: true
---

# Spring Module XML and Maven Support

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

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.

## Add a Namespace for the Connector

Paste the following code inside the `<mule>` tag of the header of your configuration XML:

```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:

```xml
<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">
```

## Add a POM File Dependency

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:

```xml
<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:

1.  Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/).

2.  In Exchange, click **Login** and supply your Anypoint Platform username and password.

3.  In Exchange, search for `spring module`.

4.  Select the connector.

5.  Click **Dependency Snippets** near the upper right of the screen.

## Set Up Spring 7 Libraries in the pom.xml File

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.

1.  Add the Spring libraries as shared libraries in the `configuration` element of the
    `mule-maven-plugin`:

    ```xml
    <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>
    ```

2.  Add the Spring 7 libraries as dependencies in the `dependencies` element:

    ```xml
    <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.

## See Also

- [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)

- [Salesforce Help](https://help.salesforce.com)
