没有合适的资源?快使用搜索试试~ 我知道了~
SpringBoot配置Apollo代码实例
11 下载量 134 浏览量
2020-08-25
12:40:27
上传
评论
收藏 34KB PDF 举报
温馨提示


试读
2页
主要介绍了SpringBoot配置Apollo代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
资源推荐
资源详情
资源评论















SpringBoot配置配置Apollo代码实例代码实例
主要介绍了SpringBoot配置Apollo代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一
定的参考学习价值,需要的朋友可以参考下
这篇文章主要介绍了SpringBoot配置Apollo代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参
考学习价值,需要的朋友可以参考下
Windows环境安装下载,参考:https://github.com/ctripcorp/apollo
项目引用项目引用
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>1.4.0</version>
</dependency>
引入引入jar包后,项目配置包后,项目配置
入口方法加入注解配置入口方法加入注解配置
@EnableApolloConfig
package top.xzhand;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableApolloConfig
@MapperScan("top.xzhand.mapper")
public class JuneApplication {
public static void main(String[] args){
SpringApplication.run(JuneApplication.class,args);
}
}
yml 文件配置项文件配置项
# 阿波罗配置
app:
id: juneweb-apollo
apollo:
# 注册路径,阿波罗默认注册配置 Eureka
meta: http://localhost:8080
bootstrap:
enabled: true
# 指定阿波罗中配置项名称,多个用逗号隔开
namespaces: application
配置项获取配置项获取
package top.xzhand.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.xzhand.po.Profix;
@Configuration
@EnableAutoConfiguration
public class ApolloProperties {
@Value("${juneweb-apollo}") //阿波罗配置中心中配置的key
public String prefix;
@Bean
public Profix profix(){
Profix p=new Profix();
p.setP(prefix);
System.out.println("prefix=========================**********"+prefix);
return p;
}
}
资源评论


weixin_38635323
- 粉丝: 9
- 资源: 955
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
