Springboot+Apollo

1 在Apollo中配置好信息 例如我的测试环境配置信息

  

spring.datasource.password = 123456
spring.thymeleaf.cache = false
spring.servlet.multipart.enabled = true
spring.servlet.multipart.max-file-size = 50485760
spring.servlet.multipart.max-request-size = 504857600
spring.servlet.multipart.file-size-threshold = 0
spring.servlet.multipart.resolve-lazily = false
spring.datasource.type = com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://172.17.40.134:3306/jobs
spring.datasource.username = root
spring.datasource.initialSize = 5
spring.datasource.minIdle = 5
spring.datasource.maxActive = 20
spring.datasource.maxWait = 60000
spring.datasource.timeBetweenEvictionRunsMillis = 60000
spring.datasource.minEvictableIdleTimeMillis = 300000
spring.datasource.validationQuery = SELECT 1 FROM DUAL
spring.datasource.testWhileIdle = true
spring.datasource.testOnBorrow = false
spring.datasource.testOnReturn = false
spring.datasource.poolPreparedStatements = true
spring.datasource.maxPoolPreparedStatementPerConnectionSize = 20
spring.datasource.filters = stat,wall,log4j
spring.datasource.connectionProperties = druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
mybatis.mapper-locations = classpath:mapper/*.xml
mybatis.type-aliases-package = com.souche.salt_common_01.entity
salt.api.url = http://172.17.40.126:8888
saltUserName = salt
saltPassword = salt
server.port = 8082
lantufe = http://localhost:9529/#/fastExecute
keycloak.auth-server-url = https://keycloak.dasouche-inc.net/auth
keycloak.realm = lantu
keycloak.resource = lantu-app
keycloak.security-constraints[0].authRoles[0] = user
keycloak.security-constraints[0].securityCollections[0].patterns[0] = /lantu/*
View Code

 

2添加依赖 引入Apollo

    我的配置信息是在我公司的Apollo服务器中,所以只有引入我自己公司封装的阿波罗依赖才能获取到apollo配置信息的地址

 这是配置本公司的本地仓什么的 我也不清楚,目的是获取笔者公司本地仓里面的依赖,你需要获取你公司的本底仓




nexus-releases
Local Nexus Repository
https://repo.souche-inc.com/repository/releases/


nexus-snapshots
Local Nexus Repository
https://repo.souche-inc.com/repository/snapshots/





<pluginRepositories> <pluginRepository> <id>soucheid> <name>artifactoryname> <url>https://repo.souche-inc.com/repository/public/url> pluginRepository> pluginRepositories> <repositories> <repository> <id>soucheid> <name>artifactoryname> <url>https://repo.souche-inc.com/repository/public/url> <snapshots> <enabled>trueenabled> <updatePolicy>interval:2updatePolicy> snapshots> repository> repositories>

获取笔者公司封装的apollo依赖

 <dependency>
            <groupId>com.ctrip.framework.apollogroupId>
            <artifactId>apollo-clientartifactId>
            <version>1.0.0-vault-SNAPSHOTversion>
        dependency>

 

3   指定机器的环境

 

例如 指定为开发环境 则在\opt\settings\server.properties中添加环境配置:

env=DEV

此目录不存在 则需要手动建立

 

4  配置app.id

在resource/META-INF/app.properties里面添加app.id,类型字符串(新建)

 

5 在启动类上面添加 @EnableApolloConfig

Springboot+Apollo_第1张图片

 

 

 

 

 

 

 

 

 

 

    

转载于:https://www.cnblogs.com/hhxylm/p/10593339.html

你可能感兴趣的:(Springboot+Apollo)