java - 我怎样才能使spring.xml的xsi :schemaLocation work when my app is offline (finished product is an offline artifact)

标签 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">

有人有这方面的经验吗?

最佳答案

如果您省略架构中的版本号,它们将从 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 发布之前,版本会被剥离,并且 schema 会与 jar 一起打包。在没有版本的情况下使用模式甚至是一个很好的做法,因为它可能会提前指出类路径/版本不匹配

关于java - 我怎样才能使spring.xml的xsi :schemaLocation work when my app is offline (finished product is an offline artifact),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32966049/

相关文章:

css - Twitter Bootstrap + JSP (Spring MVC) - 样式不适用

java - 监听OPUS编码流

java - 使用 Apache Commons 进行 base64 字符串解码

java - 如何将通用对象发布到 Spring Controller ?

java - Spring SimpleJdbcCall 返回错误值

java - VersionResourceResolver 不起作用

java - IntelliJ 无法解析 Cloudbees maven 插件依赖项

Java-XML 数据解析

java - Spring Schedule 方法被调用两次

java - 域文件夹在 Spring Boot 项目中起什么作用以及应该在其中存储哪些类?