在Maven中更新内置的Spring / Hibernate Archetype?

时间:2009-09-02 23:18:40

标签: spring hibernate maven-2 maven-archetype

当我根据默认的Archetype创建Spring和Hibernate项目时,当前版本的Hibernate是3.26,Spring是2.54。我怎样才能让Maven获得最新版本?我尝试将我的spring版本从2.5.4更改为2.5.6,但生成的war文件中仍然包含2.5.4。

2 个答案:

答案 0 :(得分:1)

如果您使用dependency-plugin的tree目标,您将能够看到哪些工件引入了对不需要的版本的传递依赖性。为确保它们不包含在您的战争中,您可以exclude这些依赖项。

假设某些直接依赖项foo引入了spring 2.5.4依赖项,以下配置会强制Maven无法解析该传递依赖项:

<dependency>
  <groupId>name.seller.rich</groupId>
  <artifactId>foo</artifactId>
  <version>1.0</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
    </exclusion>
  </exclusions> 
</dependency>

然后在您的POM中声明2.5.6版本意味着将包含您所需的版本:

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring</artifactId>
  <version>2.5.6</version>
</dependency>

答案 1 :(得分:0)

运行mvn dependency:tree,看看旧版本仍然被拉入的原因。