Home > Java > Easier Spring version management

Easier Spring version management

Earlier on, Spring migrated from a monolithic approach – the whole framework, to a modular one – bean, context, test, etc. so that one could decide to use only the required modules. This modularity came at a cost, however: in the Maven build configuration (or the Gradle one for that matter), one had to specify the version for each used module.



    ...
    
        
            org.springframework
            spring-webmvc
            4.0.5.RELEASE
        
        
            org.springframework
            spring-jdbc
            4.0.5.RELEASE
        
        
            org.springframework
            spring-test
            4.0.5.RELEASE
            test
        
    

Of course, professional Maven users would improve this POM with the following:



    ...
   
        4.0.5.RELEASE
    
    
        
            org.springframework
            spring-webmvc
            ${spring.version}
        
        
            org.springframework
            spring-jdbc
            ${spring.version}
        
        
            org.springframework
            spring-test
            ${spring.version}
            test
        
    

There’s an more concise way to achieve the same through a BOM-typed POM (see section on scope import) since version 3.2.6 though.



    ...
    
        
            
                org.springframework
                spring-framework-bom
                pom
                4.0.5.RELEASE
                import
            
        
    
    
        
            org.springframework
            spring-webmvc
        
        
            org.springframework
            spring-jdbc
        
        
            org.springframework
            spring-test
            test
        
    

Note that Spring’s BOM only sets version but not scope, this has to be done in each user POM.

Spring released very recently the Spring IO platform which also includes a BOM. This BOM not only includes Spring dependencies but also other third-party libraries.



    ...
    
        
            
                io.spring.platform
                platform-bom
                pom
                1.0.0.RELEASE
                import
            
        
    
    
        
            org.springframework
            spring-webmvc
        
        
            org.springframework
            spring-jdbc
        
        
            org.springframework
            spring-test
            test
        
        
            org.testng
            testng
            test
        
    

There’s one single problem with Spring IO platform’s BOM, there’s no simple mapping from the BOM version to declared dependencies versions. For example, the BOM’s 1.0.0.RELEASE maps to Spring 4.0.5.RELEASE.

To go further:

email
Send to Kindle
Categories: Java Tags: ,
  1. No comments yet.
  1. No trackbacks yet.