Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9132805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:22:38+00:00 2026-06-17T08:22:38+00:00

I wish to enforce a specific Spring version (3.1.2) using the maven-enforcer plugin ‘s

  • 0

I wish to enforce a specific Spring version (3.1.2) using the maven-enforcer plugin‘s bannedDependencies rule.

Is this the correct way to configure the enforcer plugin to achieve that ?

<configuration>
    <rules>
        <bannedDependencies>
            <searchTransitive>true</searchTransitive>
            <excludes>
                <exclude>org.springframework</exclude>
            </excludes>
            <includes>
                <include>org.springframework:*:3.1.2</include>
            </includes>
        </bannedDependencies>
    </rules>
    <fail>true</fail>
    <failFast>true</failFast>
    <ignoreCache>true</ignoreCache>
</configuration>

The above seems to work and doing a mvn enforcer:enforce on the command line highlighted that v3.1.0 or org.springframework:spring-oxm was being pulled in as a transitive dependency.

It also seems like one might want to use dependencyConvergence rule, but it highlights a lot of dependency errors which are excluded automatically as ‘conflicts’ by maven.

Here is a snippet with a bit more context :

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>${maven.enforcer.plugin}</version>
            <executions>
                <execution>
                    <id>enforce-versions</id>
                    <goals>
                        <goal>enforce</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                        <rules>
                            <bannedDependencies>
                                <searchTransitive>true</searchTransitive>
                                <excludes>
                                    <exclude>org.springframework</exclude>
                                    <exclude>org.springframework.security</exclude>
                                    <exclude>org.slf4j</exclude>
                                </excludes>
                                <includes>
                                    <include>org.springframework:*:${spring.version}</include>
                                    <include>org.springframework.security:*:${spring-security.version}</include>
                                    <include>org.slf4j:*:${slf4j.version}</include>
                                </includes>
                            </bannedDependencies>
                            <requireJavaVersion>
                                <version>${enforce.jdk.version}</version>
                            </requireJavaVersion>
                        </rules>
                        <fail>true</fail>
                        <failFast>true</failFast>
                        <ignoreCache>true</ignoreCache>
            </configuration>
        </plugin>
 .....
</plugins>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:22:39+00:00Added an answer on June 17, 2026 at 8:22 am

    The bannedDependencies snippet in the question above does not work because of the fact that the <include> tag does not understand the groupId:artifactId:version:type notation. Thus, wildcard cannot be used to replace whole sections to convey include all versions of ALL artifacts in a group.

    However, by using the maven Dependency Version Range it is possible to enforce a specific dependency.

    Given the following versions of a given artifact (in the order that they were released):

    3.0.0 , 3.0.1 , 3.1.0, 3.2.0.RELEASE, 3.3.0

    let’s say we want to tell the enforcer plugin to exclude everything but 3.2.0.RELEASE then the only way to do that is :

    exclude versions X where X < DESIRED_VERSION OR X > DESIRED VERSION

    The above would effectively mean :
    exclude all versions X where X != DESIRED_VERSION

    Since the maven dependency version notation does not permit a ‘Not Version’ notation, we have to make do with using the less than and greater than notations in combination like so:

    (,3.2.0.RELEASE),(3.2.0.RELEASE,)

    which means: version < '3.2.0.RELEASE' or version > '3.2.0.RELEASE'.

    Finally, a snippet of what works is as follows:

    <bannedDependencies>
        <searchTransitive>true</searchTransitive>
        <excludes>
            <exclude>org.springframework:*:(,${spring.version}),(${spring.version},)</exclude>    
        </excludes>
    </bannedDependencies>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to do this using only XAML - How to add an additional
I wish to make this WinForm control ( NumericUpDown ) enforce whole numbers conditionally
I wish HTML could do something semantically equivalent to this; <dl class=main-list> <definitionitem> <dt>Some
I wish I could figure this out. I need to produce a table with
I wish to write a plugin similar to the built-in documentation pane, where you
I wish to create a HTTP request header using Fiddler. I have a Service
I wish there was a way to split a #include directive across two lines,
Wish anybody can help me with this error Column 'Sales.No_' is invalid in the
I wish to make an attribute conditional based on compilation mode. For example this
I wish to have a Master-Page, and switch content in this. I currently have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.