微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

mars-config spring mvc 、springboot 动态配置系统

程序名称:mars-config

授权协议: Apache

操作系统: 跨平台

开发语言: Java

mars-config 介绍

mars-config是spring mvc 、springboot 动态配置系统。支持http 轮训方式、更新、动态配置。

软件架构说明

后端使用技术 :springboot mybatis jwt

前端使用:thymeleaf 模板引擎

数据库MysqL

jdk :1.8

  1. 先创建数据库mars_db ,导入 sql目录下的 init.sql 文件
  2. mars-console 后端管理页面,直接使用外置tomcat 启动即可 端口认:8080
  3. mars-spring-config 发布jar 后依赖当前jar 即可使用
  4. 访问地址:ip + port 账户:mars 密码:mars 权限:超级管理员
  1. 在启动类上使用 @EnableMarsConfig 开启功能使用

1、mars.config.app-id 服务名 和 后端appName 一致

2、mars.config.env-code 环境Code 和 后端envCode 一致

3、mars.config.http.server-address 服务Ip,多个服务地址已逗号分隔

  1. 在后端管理操作

1、应用环境管理 菜单 创建 应用、环境

2、配置管理 菜单 创建配置 点击发布,依赖 mars-spring-config 就会收到服务端修改内容

  1. springboot 具体使用步骤
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);
    }
}
    @MarsValue(value = "${abc}",autoRefreshed = true)
    private String abc;

@ConfigurationProperties 功能相似

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;
}
    @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());
    }
mars.config.app-id=app
mars.config.env-code=betaXX
mars.config.http.server-address=192.168.0.108:8080

参考使用demo

GitHub地址:https://github.com/fashionbrot/mars-config

mars-config 官网

https://github.com/fashionbrot/mars-config

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐