简体   繁体   English

如何覆盖Spring Batch中的spring框架版本?

[英]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. 我正在使用Spring Batch 2.1.6.RELEASE开始一个新项目,我使用Maven进行依赖管理。

By default, it imports spring framework 2.5.6, but I'd like to use 3.0.5.RELEASE instead. 默认情况下,它导入spring framework 2.5.6,但我想改用3.0.5.RELEASE。

This post says it's compatible, but I don't know how to declare that in my maven pom file. 这篇文章说它兼容,但我不知道如何在我的maven pom文件中声明它。

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. 我尝试将spring-core,spring-beans和spring-context版本3.0.5.RELEASE的依赖项放在一起,但是在不删除2.5.6版本的情况下将库添加到项目中。

I had a look at spring-batch-parent pom file, and there is a profile called "spring3" that uses the spring version I want. 我看一下spring-batch-parent pom文件,有一个名为“spring3”的配置文件,它使用我想要的spring版本。 How do I activate a profile in my project's pom file ? 如何在项目的pom文件中激活配置文件?

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. 您可以通过使用maven中spring-batch依赖项的依赖项排除元素来排除对Spring Batch的Spring Framework v2.5.6的瞬态依赖性。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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