Apollo-docker.yml

version: '3'
services:
  apollo-portal:
    image: apolloconfig/apollo-portal
    ports:
        - "9700:8070"
    environment:
      # DataSource Info
      SPRING_DATASOURCE_URL: "jdbc:mysql://192.168.1.104:3306/ApolloPortalDB?characterEncoding=utf8"
      SPRING_DATASOURCE_USERNAME: "root"
      SPRING_DATASOURCE_PASSWORD: "root"
      # Environmental variable declaration (meta server url, different environments should have different meta server addresses)
      DEV_META: http://192.168.1.104:9701
    depends_on:
      - apollo-adminservice

  apollo-configservice:
    image: apolloconfig/apollo-configservice
    ports:
        - "9701:8080"
    environment:
      # DataSource Info
      SPRING_DATASOURCE_URL: "jdbc:mysql://192.168.1.104:3306/ApolloConfigDB?characterEncoding=utf8"
      SPRING_DATASOURCE_USERNAME: "root"
      SPRING_DATASOURCE_PASSWORD: "root"

  apollo-adminservice:
    image: apolloconfig/apollo-adminservice
    ports:
        - "9702:8090"
    environment:
      # DataSource Info
      SPRING_DATASOURCE_URL: "jdbc:mysql://192.168.1.104:3306/ApolloConfigDB?characterEncoding=utf8"
      SPRING_DATASOURCE_USERNAME: "root"
      SPRING_DATASOURCE_PASSWORD: "root"
    depends_on:
      - apollo-configservice

自动刷新配置:

@Component
public class ApolloConfigChangeHandler implements ApplicationEventPublisherAware {
    private ApplicationEventPublisher applicationEventPublisher;

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher = applicationEventPublisher;
    }

    @ApolloConfigChangeListener
    public void handleApplicationConfigChange(ConfigChangeEvent event){
        this.applicationEventPublisher.publishEvent(new EnvironmentChangeEvent(event.changedKeys()));
    }
}

标签: none

添加新评论