架构版本可以与jar文件不同吗?

时间:2014-06-12 09:23:20

标签: java xml spring jar xsd

我的lib文件夹有4.0.4版本的spring jar。在applicationContext.xml我使用3.0版本的架构。

例如: 我有以下罐子:

  • 弹簧豆-4.0.4
  • 弹簧上下文4.0.4
  • 弹簧芯4.0.4
  • 弹簧表达-4.0.4
  • 小枝的Web-4.0.4
  • 弹簧webmvc-4.0.4

并在applicationContext.xml中写道:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:util="http://www.springframework.org/schema/util" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

我的问题是:

架构和jar之间可能有不同的版本吗?

如果是,会有什么后果?

1 个答案:

答案 0 :(得分:1)

尝试在xml中使用这种类型的模式:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jms="http://www.springframework.org/schema/jms"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/jms
                           http://www.springframework.org/schema/jms/spring-jms.xsd">

不要使用:context/spring-context-3.0.xsd并且喜欢这样,因为当应用程序变得更大以处理所有这些事情时非常麻烦。

如果可能,请使用maven代替jars,只需在property中定义一次版本,然后仅在dependency的pom导入中使用该版本。

相关问题