{"id":37024198,"url":"https://github.com/yangfeng20/smart-config","last_synced_at":"2026-01-14T02:55:20.986Z","repository":{"id":211038877,"uuid":"727738044","full_name":"yangfeng20/smart-config","owner":"yangfeng20","description":"Smart-Config 智能配置：单体应用下的动态配置;单机版Apollo","archived":false,"fork":false,"pushed_at":"2025-07-01T02:31:35.000Z","size":1366,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T03:35:25.643Z","etag":null,"topics":["apollo","config-center","dynamic","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yangfeng20.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-05T13:28:12.000Z","updated_at":"2025-07-01T02:28:26.000Z","dependencies_parsed_at":"2023-12-25T01:44:03.139Z","dependency_job_id":"df26c7a0-a816-42a6-86ad-f5da7e55e87f","html_url":"https://github.com/yangfeng20/smart-config","commit_stats":null,"previous_names":["yangfeng20/smart-config"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yangfeng20/smart-config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangfeng20%2Fsmart-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangfeng20%2Fsmart-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangfeng20%2Fsmart-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangfeng20%2Fsmart-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yangfeng20","download_url":"https://codeload.github.com/yangfeng20/smart-config/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangfeng20%2Fsmart-config/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo","config-center","dynamic","java"],"created_at":"2026-01-14T02:55:20.375Z","updated_at":"2026-01-14T02:55:20.973Z","avatar_url":"https://github.com/yangfeng20.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Smart-Config\n\n智能配置：单体应用下的配置中心，支持动态配置,在单体应用下拥有微服务配置中心般的体验。\n\n主要用来解决在单体应用没有配置中心时，想要动态变更配置。可以理解为单机版的Apollo。\n\n### 优势\n- 权限校验\n- 动态变更配置\n- webUi修改配置\n- 支持非SpringBoot应用\n- 无缝衔接`SpringBoot`应用\n- 支持结构化数据（json，集合，对象）\n- 轻量级无冗余第三方库\n- 内嵌轻量级jetty服务器\n- webUi支持中英文切换\n- 支持springboot多配置文件\n- 支持`spring.config.location`以及`spring.profiles.active`\n- 支持启动参数修改webUi端口以及配置描述推断\n- webUi支持默认值回显\n- 配置持久化，像使用微服务配置中心一样\n- 内置多种冲突策略，且可自定义冲突策略\n- 预留多种spi扩展接口（配置加载，配置变更，冲突合并...）\n\n\n\n### 效果展示\n\n![示例](/images/img_1.png)\n\n![示例](/images/img_2.png)\n\n\n### 使用\n\n#### 依赖引入\n\n```xml\n\u003cdependency\u003e\n   \u003cgroupId\u003eio.github.yangfeng20\u003c/groupId\u003e\n   \u003cartifactId\u003esmart-config-core\u003c/artifactId\u003e\n   \u003cversion\u003e1.0.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n- springboot3需要做单独的代码兼容，所以版本独立发布。\n- 如果使用的是springboot3，请在正常版本后添加[-springboot3]\n- 例如：\n```xml\n\u003cdependency\u003e\n   \u003cgroupId\u003eio.github.yangfeng20\u003c/groupId\u003e\n   \u003cartifactId\u003esmart-config-core\u003c/artifactId\u003e\n   \u003cversion\u003e1.0.4-springboot3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n- 同时由于springboot3中web-starter也引入了jetty依赖\n- 会发生依赖冲突，最终类找不到\n- 需要引入依赖管理，并指定jetty版本，强制使用jetty 11.0.20版本\n```xml\n    \u003cdependencyManagement\u003e\n        \u003cdependencies\u003e\n            \u003c!--smart-config jetty--\u003e\n            \u003cdependency\u003e\n                \u003cgroupId\u003eorg.eclipse.jetty\u003c/groupId\u003e\n                \u003cartifactId\u003ejetty-bom\u003c/artifactId\u003e\n                \u003cversion\u003e11.0.20\u003c/version\u003e\n                \u003ctype\u003epom\u003c/type\u003e\n                \u003cscope\u003eimport\u003c/scope\u003e\n            \u003c/dependency\u003e\n        \u003c/dependencies\u003e\n    \u003c/dependencyManagement\u003e\n```\n\n\n1. Spring-Boot使用\n\n    主类添加注解`@EnableSmartConfig`\n    ```java\n    @EnableSmartConfig\n    public class XxxApplication {\n        ApplicationContext application = SpringApplication.run(XxxApplication.class, args);\n    }\n    ```\n   \n   使用@Value注解\n   ```java\n   public class AppConfig{\n   \n      @Value(\"${configKey}\")\n      private String value;\n      \n      @JsonValue(\"${list:[1]}\")\n      private List\u003cInteger\u003e list;\n      \n      @JsonValue(\"${config.entity:{}}\")\n      private XxxEntity entity; \n   \n   } \n   ```\n\n2. 非spring项目使用\n\n   创建LocalFileConfig对象，参数分别为webUi的端口，是否推断配置描述。\n    ```java\n    public class App{\n        public static void main(String[]args){\n            SmartConfig smartConfig = new LocalFileConfig(6767, true);\n            List\u003cString\u003e list = new ArrayList\u003c\u003e();\n            list.add(\"com.maple.smart.config.test\");\n            AbsConfigBootstrap bootstrap = new LocalConfigBootstrap(true, 6767,\"classpath:application.properties\", list);\n            bootstrap.init();\n        }\n    }   \n    ```\n   静态类的静态字段使用@SmartValue注解\n   ```java\n   public class AppConfig{\n   \n       @SmartValue(\"配置key:默认值\")\n       private static String config1;\n   \n       @SmartValue(\"biz.name:abc\")\n       private static String bizName;\n   \n       @JsonValue(\"${list:[1]}\")\n       private static List\u003cInteger\u003e list;\n      \n       @JsonValue(\"${config.entity:{}}\")\n       private static XxxEntity entity; \n   }\n   ```\n   \n\n### 注意\n- Web-Ui默认端口：6767\n- SpringBoot应用配置类被代理后请勿直接访问属性，而是通过getter访问\n- 非Spring应用仅支持静态变量。\n- 默认值回显开启时，如果key有两个默认值，即在代码中使用直接使用注解引用key，并且在配置文件中不存在。\n  ```java\n    @JsonValue(\"${list:[]}\")\n    public List\u003cInteger\u003e list1;\n  \n    @JsonValue(\"${list:[1,2,3]}\")\n    public List\u003cInteger\u003e list2;\n   ```\n    - webui中显示的值为最后一次赋值的默认值，这个顺序为容器决定\n    - 多个默认值不建议使用默认值回显功能，可能导致webui展示与代码中默认值不一致\n- `@Value`暂不支持默认值回显，请使用`@JsonValue`或者`@SmartValue`\n\n\n### 后续计划\n- [x] web配置中心展示默认值配置\n- [x] 定时在操作系统临时目录保存一份最新配置；加载时合并\n- spel支持\n- 环境变量以及jvm参数数据源支持\n- [x] 导出配置（最好格式不变）\n- yaml格式文件支持\n- 配置增加数据来源字段（配置文件，系统临时文件，代码默认值...）\n\n### 测试运行\n- 如果要直接跑当前项目的源代码，请先切换到对应分支。springboot3切换到springboot3分支。其他切换到master分支。\n- 并在不同的分支选择不同的jdk版本。springboot3选择jdk17以上即可","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyangfeng20%2Fsmart-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyangfeng20%2Fsmart-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyangfeng20%2Fsmart-config/lists"}