spring cloud 配置中心
程序员文章站
2022-03-04 09:34:23
...
@EnableConfigServer @EnableDiscoveryClient @SpringBootApplication public class ConfigCenterApplication { public static void main(String[] args) { SpringApplication.run(ConfigCenterApplication.class, args); } } pom.xml
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency>
application.yml
logging.level.com.netflix: error server: port: 10005 spring: application: name: config-service eureka: instance: prefer-ip-address: true instance-id: ${spring.cloud.client.ip-address}:${server.port} lease-renewal-interval-in-seconds: 1 lease-expiration-duration-in-seconds: 2 --- spring: profiles: sit cloud: config: server: git: uri: http://xx.xx.xx.xx/config/vcs/config-repo.git search-paths: vcs-* force-pull: true username: xx password: xx basedir: ./config-repo timeout: 10 eureka: client: service-url: defaultZone: http://xx.xx.xx.xx:10001/eureka/ --- spring: profiles: uat cloud: config: server: git: uri: http://1xx.xx.xx.xx/config/vcs/config-repo.git search-paths: vcs-* force-pull: true username: xx password: xx basedir: ./config-repo timeout: 10 eureka: client: service-url: defaultZone: http://1xx.xx.xx.xx:10001/eureka/
Dockerfile
FROM openjdk:8-jdk-alpine ENV LANG C.UTF-8 VOLUME /tmp ARG JAR_FILE ADD ${JAR_FILE} app.jar RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo /Asia/Shanghai > /etc/timezone ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar --spring.profiles.active=$PROFILE" ]
推荐阅读
-
Spring Cloud出现Options Forbidden 403问题解决方法
-
Spring+SpringMVC配置事务管理无效原因及解决办法详解
-
Spring Cloud Alibaba Nacos 入门详解
-
Spring 3.x中三种Bean配置方式比较详解
-
spring boot使用sharding jdbc的配置方式
-
Spring Boot 与 mybatis配置方法
-
Spring的注解配置与XML配置之间的比较
-
Spring Boot自定义配置属性源(PropertySource)
-
spring 如何将配置信息注入静态变量的方法
-
spring cloud consul使用ip注册服务的方法示例