【问题标题】:Docker container not able to read http link - camelDocker 容器无法读取 http 链接 - 骆驼
【发布时间】:2017-12-15 10:02:30
【问题描述】:

所以我正在为 Windows 中的Camel Spring boot 项目之一创建一个 docker 容器。在项目中,在我的camelcontext.xml开头我有以下一段代码-

<beans 
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:camel="http://camel.apache.org/schema/spring" 
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:security="http://www.springframework.org/schema/security"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd 
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    .
    .
    // remaining part of code

现在,对于 xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd ..." 部分,docker 容器无法访问 .xsd 文件。

另外,不确定是否相关,我有另一个单独的容器,其中包含 jhipster 应用程序,我可以在本地浏览器中打开该应用程序。我还做了一些在线链接中发现的 DNS 更改。 (我的意思是在创建的虚拟交换机中添加 8.8.8.8 和 8.8.4.4)

不知道为什么我无法从容器中访问文件以及问题出在哪里。

以下是我得到的错误 -

线程“main”中的异常 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 来自类路径资源的 XML 文档中的第 10 行 [META-INF/spring/camelContext.xml] 无效;嵌套异常是 org.xml.sax.SAXParseException;行号:10;列号:44; cvc-elt.1:找不到元素“beans”的声明。

org.xml.sax.SAXParseException;行号:10;列号:44; cvc-elt.1:找不到元素“beans”的声明。

line 10, column 44 是我在上面粘贴的代码。

PS - xml 文件已验证,我检查它here

【问题讨论】:

    标签: docker spring-boot apache-camel


    【解决方案1】:
    1. www.springframework.org替换为可以通过pingwww.springframework.org获取的IP地址,确保问题与DNS无关

    2. 在 docker run 命令中使用--network=host 启动容器。

    【讨论】:

    • 您在camelcontext.xml 中的意思是什么?对于--network=host,我应该把什么作为主持人?我的本地 IP?
    • 是的。只需对其进行测试以确保问题与 DNS 无关。
    • 嗨@yamenk,我尝试了你的建议 - 用 IP 地址更改了 url 并添加了 --network=host。还使用-v 映射了我的目录,但没有得到任何解决方案。我已经添加了我在问题中遇到的错误。
    猜你喜欢
    • 2018-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-26
    • 2020-12-22
    • 1970-01-01
    相关资源
    最近更新 更多