Docker容器无法读取http链接 - 驼峰

问题描述 投票:0回答:1

所以我正在为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:来自类路径资源[META-INF / spring / camelContext.xml]的XML文档中的第10行无效;嵌套异常是org.xml.sax.SAXParseException; lineNumber:10; columnNumber:44; cvc-elt.1:找不到元素'beans'的声明。

org.xml.sax.SAXParseException; lineNumber:10; columnNumber:44; cvc-elt.1:找不到元素'beans'的声明。

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

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

docker spring-boot apache-camel
1个回答
0
投票
  1. 通过将www.springframework.org替换为可以通过ping www.springframework.org获得的ip地址,确保问题与DNS无关
  2. 在docker run命令中使用--network=host启动容器。
© www.soinside.com 2019 - 2024. All rights reserved.