简体   繁体   中英

How do I override the spring framework version in Spring Batch?

I'm starting a new project with Spring Batch 2.1.6.RELEASE and I use Maven for depemdency management.

By default, it imports spring framework 2.5.6, but I'd like to use 3.0.5.RELEASE instead.

This post says it's compatible, but I don't know how to declare that in my maven pom file.

I tried just putting the dependencies for spring-core, spring-beans and spring-context versions 3.0.5.RELEASE, but that adds the libraries to the project without removing the 2.5.6 version.

I had a look at spring-batch-parent pom file, and there is a profile called "spring3" that uses the spring version I want. How do I activate a profile in my project's pom file ?

Thanks in advance,

Philippe

You can exclude the transient dependency on Spring Framework v2.5.6 of Spring Batch by using the dependency exclusions element of the spring-batch dependency in maven. Something like...

<dependency>
  <groupId>org.springframework.batch</groupId>
  <artifactId>spring-batch-core</artifactId>
  <version>2.1.6.RELEASE</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework</groupId> 
      <artifactId>spring-beans</artifactId> 
    </exclusion>
    <!-- Other exclusions here -->
  </exclusions> 
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM