日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

怎么在SpringBoot中配置Apollo

發(fā)布時(shí)間:2023/12/15 综合教程 34 生活家
生活随笔 收集整理的這篇文章主要介紹了 怎么在SpringBoot中配置Apollo 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

怎么在SpringBoot中配置Apollo?針對這個(gè)問題,這篇文章詳細(xì)介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問題的小伙伴找到更簡單易行的方法。

項(xiàng)目引用

<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>1.4.0</version>
</dependency>

引入jar包后,項(xiàng)目配置

入口方法加入注解配置

@EnableApolloConfig

packagetop.xzhand;

importcom.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
importorg.mybatis.spring.annotation.MapperScan;
importorg.springframework.boot.SpringApplication;
importorg.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableApolloConfig
@MapperScan("top.xzhand.mapper")
publicclassJuneApplication{

publicstaticvoidmain(String[]args){
SpringApplication.run(JuneApplication.class,args);
}
}

yml 文件配置項(xiàng)

#阿波羅配置
app:
id:juneweb-apollo
apollo:
#注冊路徑,阿波羅默認(rèn)注冊配置Eureka
meta:http://localhost:8080
bootstrap:
enabled:true
#指定阿波羅中配置項(xiàng)名稱,多個(gè)用逗號隔開
namespaces:application

配置項(xiàng)獲取

packagetop.xzhand.config;

importorg.springframework.beans.factory.annotation.Value;
importorg.springframework.boot.autoconfigure.EnableAutoConfiguration;
importorg.springframework.context.annotation.Bean;
importorg.springframework.context.annotation.Configuration;
importtop.xzhand.po.Profix;

@Configuration
@EnableAutoConfiguration
publicclassApolloProperties{
@Value("${juneweb-apollo}")//阿波羅配置中心中配置的key
publicStringprefix;
@Bean
publicProfixprofix(){
Profixp=newProfix();
p.setP(prefix);
System.out.println("prefix=========================**********"+prefix);
returnp;
}
}

總結(jié)

以上是生活随笔為你收集整理的怎么在SpringBoot中配置Apollo的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。