【问题标题】:Spring Boot 2.0.0 with Spring Integration Http Namespace not found找不到带有 Spring Integration Http 命名空间的 Spring Boot 2.0.0
【发布时间】:2018-01-10 18:22:27
【问题描述】:

我想构建一个带有 Spring 集成 http 支持的 Spring Boot 2 应用程序。但我找不到 int-http 命名空间。

我的 XML:

<int-http:outbound-gateway id="quakerHttpGateway"
     request-channel="quakeinfotrigger.channel"
     url="http://..."
     http-method="GET"
     expected-response-type="java.lang.String"
     charset="UTF-8"
     reply-timeout="5000"
     reply-channel="quakeinfo.channel">     
 </int-http:outbound-gateway>

分级:

buildscript {
    ext {
        springBootVersion = '2.0.0.M7'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'myCompany'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-integration')
    compile('org.springframework.integration:spring-integration-http')
    compile('org.codehaus.groovy:groovy')
    runtime('com.h2database:h2')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

【问题讨论】:

  • 由于自我回答中给出的解决方案是微不足道的,因此可以关闭/删除 IMO 的问题。

标签: spring-boot groovy spring-integration spring-integration-http


【解决方案1】:

您应该在 XML 配置的开头显示 xsi:schemaLocation 定义,当然还有演示和例外。因为这是 Spring Boot 应用程序,如果在 GitHub 上的某个地方分享它的简单版本,让我们在本地下载并播放它,那就太好了。

另外请记住,Eclipse 默认不会从类路径解析 XSD,您需要启用 Spring Nature 或开始使用 Spring 兼容的 IDE。 (如果是 IDE 的情况,不是运行时问题)。

由于您使用了正确的 org.springframework.integration:spring-integration-http 依赖项,因此 XSD 就在那个 jar 中。只有您需要记住的是,我们推荐“无版本”模式定义,或者只使用您所依赖的 jar 版本(次要版本)。使用 Spring Boot 2.05.0: https://docs.spring.io/spring-integration/docs/5.0.0.RELEASE/reference/htmlsingle/#configuration-namespace

【讨论】:

  • 您好,Artem,感谢您的回复。该项目具有 Spring Nature,但没有可供 int-http 选择的命名空间。我不知道,为什么它不显示,我使用的是 STS 3.9.2
  • 不确定您在此处显示的内容,但您确实必须将 int-http 定义添加到 XML 配置的头部:docs.spring.io/spring-integration/docs/5.0.0.RELEASE/reference/…
  • IIRC,如果您在文件打开时添加依赖项,则在您关闭/重新打开 XML 之前,新的命名空间不会显示。
  • 嗨,Gary,我重新打开了它,我重新启动了 STS,但它没有出现...我现在更新工作区...
  • 对我来说,编辑器似乎无法正常工作,我按照您建议的 Artem 复制了 xml 的一部分,但它没有显示在通常可以选择的命名空间列表中。
猜你喜欢
  • 2015-02-25
  • 2017-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多