Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XDB docker映像不';无法使用我的Spring Boot应用程序映像_Spring_Spring Boot_Docker - Fatal编程技术网

XDB docker映像不';无法使用我的Spring Boot应用程序映像

XDB docker映像不';无法使用我的Spring Boot应用程序映像,spring,spring-boot,docker,Spring,Spring Boot,Docker,我正在尝试使用docker compose--build命令构建一个应用程序。但是,我得到以下错误: nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'influxDB' defined in class path resource [com/order/app/config/InfluxDatabaseConfig.class

我正在尝试使用docker compose--build命令构建一个应用程序。但是,我得到以下错误:

nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 
'influxDB' defined in class path resource [com/order/app/config/InfluxDatabaseConfig.class]: Bean instantiation via factory method failed; 
nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [org.influxdb.InfluxDB]: 
Factory method 'influxDB' threw exception; 
nested exception is org.influxdb.InfluxDBIOException: 
java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8086
这是我的docker-compose.yml:

    version: '3'
services:
  influx:
    image: influxdb
    container_name: influxdb
    environment:
      INFLUXDB_DB: test
      INFLUXDB_ADMIN_USER: admin
      INFLUXDB_ADMIN_PASSWORD: admin
      INFLUXDB_HTTP_AUTH_ENABLED: "true"
    ports:
      - 8081:8081/tcp
  backend:
    container_name: order-app
    image: order-app
    build: .
    ports:
      - "8080:8080"
    depends_on:
      - influx
下面是我的InfluxDatabaseConfig类:

@Configuration
@EnableConfigurationProperties(InfluxDBProperties.class)
public class InfluxDatabaseConfig {
    @Bean
    public InfluxDB influxDB() {
        InfluxDB connection = InfluxDBFactory.connect("http://localhost:8086", "admin", "admin");
        connection.createDatabase("test");
        connection.setDatabase("test");
        return connection;
    }
}

application.properties文件:

server.port=8080
spring.influxdb.database=test
spring.influxdb.url=http://localhost:8086
spring.influxdb.username=admin
spring.influxdb.password=admin
spring.influxdb.retention-policy=autogen
spring.influxdb.gzip=true


有人知道我的代码中可能有什么错误吗?非常感谢您的帮助。

您的流入容器和后端在两个不同的容器中运行,这意味着它们是两台不同的机器,每台机器都有自己的ip

您不能使用
localhost:8086从后端容器调用influx db

要访问influxdb,您必须调用influxcontainer ip或name或service name

同时将流入中的暴露端口更新为
8086:8086


在您的情况下,更改
http://localhost:8086
value to
inflow:8086
并尝试一下

您的inflow容器和后端在两个不同的容器中运行,这意味着它们是两台不同的机器,每台机器都有自己的ip

您不能使用
localhost:8086从后端容器调用influx db

要访问influxdb,您必须调用influxcontainer ip或name或service name

同时将流入中的暴露端口更新为
8086:8086

在您的情况下,更改
http://localhost:8086
要输入的值:8086
并尝试一下