Question

I'm trying to add Spring BOM to my project. My POM is below.

  1. Am I not doing something correctly here?
  2. Also, a semi-related question: why do the version numbers for spring-ws, spring-data-jpa, and others not line up with the version of spring core, context, etc?

    <build>
        <finalName>myproject</finalName>
        <plugins>
            <plugin>
                <version>3.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-framework-bom</artifactId>
                <version>4.0.3.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </dependency>
        ...
        </dependencies>
    </dependencyManagement>
    
    <dependencies>
    
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>${spring-ws.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>${spring-data-jpa.version}</version>
        </dependency>
    ...
    </dependencies>
    

It produces the following error:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.863s
[INFO] Finished at: Fri May 09 13:15:24 EDT 2014
[INFO] Final Memory: 17M/214M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on
project myproject: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin
:2.1.1:war failed: For artifact {org.springframework:spring-core:null:jar}: The version cannot be em
pty. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plug
ins:maven-war-plugin:2.1.1:war (default-war) on project myproject: Execution default-war o
f goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war failed: For artifact {org.springframework
:spring-core:null:jar}: The version cannot be empty.
Was it helpful?

Solution

The non-BOM Spring dependencies go in the dependencies section, not dependencyManagement.

<dependencies>

    <!-- Spring -->
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>${spring-ws.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>${spring-data-jpa.version}</version>
    </dependency>
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>
</dependencies>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top