详解Springboot中apollo
小编这次要给大家分享的是详解Springboot中apollo,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。
海东ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!
添加配置

spring-boot中如何使用
pom.xml中添加配置
com.ctrip.framework.apollo apollo-client 1.1.0
配置文件中添加apollo地址
app: id: komiles apollo: meta: http://106.54.227.205:8080 bootstrap: enabled: true namespaces: application
启动类中添加代码
添加@EnableApolloConfig注解
package com.example.apollodemo;
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("com.example.apollodemo.mapper")
public class ApolloDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ApolloDemoApplication.class, args);
System.out.println("============ apollo demo application end =============");
}
}controller类新增文件
ApolloController.java
package com.example.apollodemo.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author komiles@163.com
* @date 2020-05-06 17:28
*/
@RestController
@RequestMapping("/apollo")
public class ApolloController {
@Value("${name}")
private String name;
@GetMapping("/name")
public String name()
{
return name;
}
}可以读取到配置为kongming.
数据库配置如何使用?
同理,generatorConfig.xml中也可以读取数据库配置
<?xml version="1.0" encoding="UTF-8"?>
看完这篇关于详解Springboot中apollo的文章,如果觉得文章内容写得不错的话,可以把它分享出去给更多人看到。
名称栏目:详解Springboot中apollo
文章地址:http://www.jxjierui.cn/article/ppccch.html


咨询
建站咨询
