mars-config 动态配置管理
2019-12-12 12:13
1216 查看
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
mars-config
码云地址:https://gitee.com/fashionbrot/mars-config
介绍
spring mvc 、springboot 动态配置系统。http 轮训方式 更新 动态配置
软件架构
软件架构说明
后端使用技术 :springboot mybatis jwt
前端使用:thymeleaf 模板引擎
数据库 :mysql
jdk :1.8
安装教程
- 先创建数据库mars_db ,导入 sql目录下的 init.sql 文件
- mars-console 后端管理页面,直接使用外置tomcat 启动即可 端口默认:8080
- mars-spring-config 发布jar 后依赖当前jar 即可使用
- 访问地址:ip + port 账户:mars 密码:mars 权限:超级管理员
使用说明
-
在启动类上使用 @EnableMarsConfig 开启功能使用
1、mars.config.app-id 服务名 和 后端appName 一致
2、mars.config.env-code 环境Code 和 后端envCode 一致
3、mars.config.http.server-address 服务Ip,多个服务地址已逗号分隔
-
在后端管理操作
1、应用环境管理 菜单 创建 应用、环境
2、配置管理 菜单 创建配置 点击发布,依赖 mars-spring-config 就会收到服务端修改内容
-
springboot 具体使用步骤
1、在启动类上添加 @EnableMarsConfig 开启mars 动态配置
import com.gitee.mars.spring.config.annotation.EnableMarsConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) @EnableMarsConfig public class Main extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(Main.class, args); } }
2、通过 @MarsValue 获取动态配置的值 如同spring @Value 功能 autoRefreshed 表示是否自动更新当前值
@MarsValue(value = "${abc}",autoRefreshed = true) private String abc;
3、通过@MarsConfigurationProperties 注解把对应配置映射到 TestConfig 类中,如springboot @ConfigurationProperties 功能相似
@MarsProperty 读取配置key @MarsIgnoreField忽略abc字段配置
import com.gitee.mars.spring.properties.annotation.MarsConfigurationProperties; import com.gitee.mars.spring.properties.annotation.MarsIgnoreField; import com.gitee.mars.spring.properties.annotation.MarsProperty; import lombok.Data; @Data @MarsConfigurationProperties(fileName = "aaa",autoRefreshed = true) public class TestConfig { @MarsProperty("abc") public String name ; @MarsIgnoreField private String abc; }
4、通过 @MarsConfigListener 监听文件变化,可根据需要使用
@MarsConfigListener(fileName = "aaa",type = ConfigTypeEnum.TEXT) public void marsConfigListenerTest(String context){ System.out.print(context); } @MarsConfigListener(fileName = "aaa",type = ConfigTypeEnum.PROPERTIES) public void marsConfigListenerProperties(Properties properties){ System.out.print(properties.toString()); }
5、在配置文件中添加以下配置
mars.config.app-id=app mars.config.env-code=betaXX mars.config.http.server-address=192.168.0.108:8080
6、可通过 mars-test项目中的 springboot-test 参考使用 demo
7、后端管理系统支持 properties yaml text 三种配置格式
8、后端管理系统支持 权限管理,可根据不同人分配不同菜单、不同配置权限
9、如有问题请通过 mars-issue 提出问题我们非常认真地对待错误和缺陷
相关文章推荐
- 利用程序动态管理Web.config文件的配置
- 利用程序动态管理Web.config文件的配置
- SpringCloud(第 028 篇)ConfigServer 配置管理微服务
- ASP.NET的配置管理---web.config
- SpringCloud(第 036 篇)单点手动动态刷新ConfigClient配置
- 通过config文件配置动态导入模块
- 详解MySQL Cluster管理结点的config.ini配置文件
- Spring动态对Quartz定时任务的管理,实现动态加载,停止的配置实例代码
- 四行代码动态修改web.config文件appsettings配置节内容
- CodeIgniter框架源码笔记(7)——强大的配置管理器:配置类Config.php
- spring cloud :统一管理配置文件config
- CI框架源码阅读笔记7 配置管理组件 Config.php
- .NET Core微服务之基于Steeltoe使用Spring Cloud Config统一管理配置
- 如何删掉动态nat地址池配置命令R1(config)#ip nat pool zjb 222.52.133.10 222.52.133.20 netmask 255.255.255.0
- Spring Cloud Config 之svn配置仓库与动态刷新(客户端手动手动刷新)
- 【项目管理】generatorConfig.xml配置信息详细
- 动态读取配置文件 config
- asp.net 动态操作配置文件 web.config
- ASP.NET的配置管理---web.config
- Krpano学习:认识全景生成.bat文件及其相关配置文件(三) 在C#中修改.config文件内容(动态修改全景输入路径、名称等)