当我的应用程序处于脱机状态时,如何使spring.xml的xsi:schemaLocation工作(成品是脱机工件)

时间:2015-10-06 09:13:15

标签: java spring spring-mvc

我有一个只能脱机工作的应用程序,但由于项目的设置方式,它需要启动互联网连接。我知道问题是spring.xml中的xsi:schemaLocation属性,但是不太了解Spring,知道如何在本地设置指向模式的项目。

<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:mongo="http://www.springframework.org/schema/data/mongo"
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-4.0.xsd
    http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.5.xsd">

有没有人有这方面的经验?

1 个答案:

答案 0 :(得分:1)

如果你从模式中省略了版本号,它们将从jar文件中加载,所以

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/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd

在Spring jar发布之前,版本被剥离,模式与jar一起打包。它甚至是一个很好的做法,使用没有版本的模式,因为它可能指向早期类路径/版本不匹配