> Markdown version of [Configure pom.xml for Vaadin 7](https://vaadin.com/docs/next/tools/mpr/introduction/1-maven-v7). Section index: [llms.txt](https://vaadin.com/docs/next/tools/llms.txt)

# Configure pom.xml for Vaadin 7

## <a id="maven-setup"></a>Maven Setup

MPR is an integral part of Vaadin. Therefore, the supported version of the project is set for you when importing the platform into your project. You only need to define the platform version like so:

```xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-bom</artifactId>
            <type>pom</type>
            <scope>import</scope>
            <version>25.4.0-alpha1</version>
        </dependency>
    </dependencies>
</dependencyManagement>
```

You would then declare the usage of `vaadin-core` and `mpr-v7` like this:

```xml
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-core</artifactId>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>mpr-v7</artifactId>
</dependency>
```

### <a id="framework-7-dependency"></a>Framework 7 Dependency

When using MPR, the minimum requirement for Vaadin 7 is version 7.7.36 or later.

```xml
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-server-mpr-jakarta</artifactId>
    <version>7.7.49</version>
    <exclusions>
        <exclusion>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-elemental</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-themes</artifactId>
    <version>7.7.49</version>
</dependency>
```

You need to remove the `vaadin-client-compiled` dependency since a custom widget set is served by the MPR project.

When using MPR, you can’t use a Content Delivery Network (CDN) for the widget set. As a result, the configuration `<vaadin.widgetset.mode>cdn</vaadin.widgetset.mode>` or `<vaadin.widgetset.mode>fetch</vaadin.widgetset.mode>` should be removed.

### <a id="exclude-incompatible-framework-7-dependency"></a>Exclude Incompatible Framework 7 Dependency

A project may depend on artifacts that transitively bring in the `vaadin-server` legacy library. This artifact conflicts with `vaadin-server-mpr-jakarta`. Its presence may provoke unexpected errors at runtime. Therefore, for each of these dependencies, your configuration must explicitly exclude `vaadin-server`.

The simplest way to do this is to add an explicit dependency with `provided` scope. This way the `vaadin-server` artifact is not considered when packaging the application. Here’s how that would look:

```xml
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-server</artifactId>
    <version>{vaadin-seven-version}</version>
    <scope>provided</scope>
</dependency>
```

This approach may produce unexpected behavior during development since the `provided` scope means that the dependency is expected to be provided at runtime. For example, the IDE may give wrong code completion, open the wrong source class when inspecting code, or fail to stop at breakpoints during debugging. To avoid these issues, the legacy `vaadin-server` should not be added to the project `pom.xml` file, and exclusions should be added manually to dependencies that transitively import it.

Maven `dependency:tree` goal can be used to detect the presence of a dependency that transitively imports `vaadin-server`. Using the latest version of the plugin is recommended for better results.

```terminal
mvn dependency:tree -Dincludes=com.vaadin:vaadin-server -Dverbose=true
```

To simplify the operation, the following profile can be added to the `pom.xml` file:

```xml
<profile>
    <id>check-vaadin-server-deps</id>
    <build>
        <defaultGoal>dependency:tree</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.5.0</version>
                <configuration>
                    <includes>com.vaadin:vaadin-server</includes>
                    <verbose>true</verbose>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>
```

With this profile, run `mvn -Pcheck-vaadin-server-deps` to get the list of dependencies to fix. For each dependency found, add an exclusion for `vaadin-server` artifact, as shown in the example here:

Exclusion of `vaadin-server` transitive dependency

```xml
<dependency>
        <groupId>org.vaadin</groupId>
        <artifactId>an-addon</artifactId>
        <version>1.2.3</version>
    <exclusions>
        <exclusion>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server</artifactId>
        </exclusion>
    </exclusions>
</dependency>
```

### <a id="incompatible-dependency-at-build-time"></a>Incompatible Dependency at Build Time

To ensure that `vaadin-server` is not transitively imported by any dependency, you can configure the Maven enforcer plugin to stop the build with a failure if a reference to the artifact is detected. You would do that like this:

```xml
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>ensure-vaadin-server-not-present</id>
            <goals>
                <goal>enforce</goal>
            </goals>
            <configuration>
                <rules>
                    <bannedDependencies>
                        <excludes>
                            <exclude>com.vaadin:vaadin-server</exclude>
                        </excludes>
                        <message><![CDATA[
'com.vaadin:vaadin-server' is not compatible with Jakarta Servlet 5+ and must be excluded from dependencies
run 'mvn -Pcheck-vaadin-server-deps' to locate the sources of the banned dependencies
and add an exclusion to the dependency declaration

<dependency>
<groupId>org.vaadin</groupId>
<artifactId>an-addon</artifactId>
<version>1.2.3</version>
<exclusions>
    <exclusion>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
    </exclusion>
</exclusions>
</dependency>
                        ]]></message>
                    </bannedDependencies>
                </rules>
                <fail>true</fail>
                <failFast>true</failFast>
            </configuration>
        </execution>
    </executions>
</plugin>
```

### <a id="maven-plugins"></a>Maven Plugins

You need to add the `vaadin-maven-plugin` for it to manage the custom legacy widget set — if it’s not already in your build section. The Maven plugin version used currently is 7.7.49.

```xml
<build>
     <plugins>
         <plugin>
             <groupId>com.vaadin</groupId>
             <artifactId>vaadin-maven-plugin</artifactId>
             <version>7.7.49</version>
             <executions>
                 <execution>
                     <goals>
                         <goal>resources</goal>
                         <goal>update-widgetset</goal>
                         <goal>compile</goal>
                     </goals>
                 </execution>
             </executions>
         </plugin>
     </plugins>
 </build>
```

Vaadin 14 also requires a Maven plugin for processing frontend resources during development time. Because the `vaadin-maven-plugin` can only be defined with one version, you’ll have to use instead the `flow-maven-plugin`. This forces you to define manually the plugin version since Maven doesn’t allow you to define a plugin version in the Bill-of-Materials (BOM).

```xml
<build>
     <plugins>
         <plugin>
             <groupId>com.vaadin</groupId>
             <artifactId>flow-maven-plugin</artifactId>
             <version>25.4.0-alpha1</version>
             <executions>
                 <execution>
                     <goals>
                         <goal>prepare-frontend</goal>
                     </goals>
                 </execution>
             </executions>
         </plugin>
     </plugins>
 </build>
```

### <a id="logging"></a>Logging

To display Flow application logs, any slf4j implementation should be added to the project. The easiest way would be to use `slf4j-simple` dependency like so:

```xml
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.25</version>
</dependency>
```

The next step is [Removing legacy servlets](https://vaadin.com/docs/next/tools/mpr/introduction/2-legacy-servlets.md).

## <a id="appendix-sample-pom-xml"></a>Appendix: Sample pom.xml

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>my-mpr-app</artifactId>
    <packaging>war</packaging>
    <version>0.1</version>

    <properties>
        <vaadin.version>7.7.49</vaadin.version>
        <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
        <!-- Flow version needs to be defined manually for Flow Maven plugin
             because Maven BOMs don't support plugin versions or defining properties.
             The Flow version to use can be checked from vaadin-bom. -->
        <flow.version>25.4.0-alpha1</flow.version>

        <slf4j.version>1.7.25</slf4j.version>
        <jetty.plugin.version>11.0.13</jetty.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <type>pom</type>
                <scope>import</scope>
                <version>25.4.0-alpha1</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>mpr-v7</artifactId>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server-mpr-jakarta</artifactId>
            <version>${vaadin.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jsoup</groupId>
                    <artifactId>jsoup</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-elemental</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-themes</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>resources</goal>
                            <goal>update-widgetset</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Since the Vaadin Maven plugin can only be defined with one version,
                 the Flow Maven plugin is used instead for handling Vaadin 14+ frontend
                 resources for development and production builds. -->
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-maven-plugin</artifactId>
                <version>${flow.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- The Jetty plugin allows the development build to be
				 tested by running jetty:run on the command line. -->
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.plugin.version}</version>
                <configuration>
                    <scanIntervalSeconds>2</scanIntervalSeconds>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
```

`ABBF85AC-427F-48AC-8E40-2D6F509C378E`
