# fineely-config **Repository Path**: kepler_16b/fineely-config ## Basic Information - **Project Name**: fineely-config - **Description**: A Lightweight System Configuration Framework - **Primary Language**: Java - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-04-10 - **Last Updated**: 2023-05-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: Java, JPA, MyBatis ## README # [Fineely Config](http://www.fineely.com/) A Lightweight System Configuration Framework [![Maven Central](https://img.shields.io/static/v1?label=maven-central&message=v1.0.6&color=blue)](https://central.sonatype.com/artifact/com.fineely/fineely-config/1.0.6) [![CSDN](https://img.shields.io/static/v1?label=KeplerLei&message=CSDN&color=red)](https://blog.csdn.net/leichengjun_510/article/details/130108951) ![Libraries.io dependency status for GitHub repo](https://img.shields.io/static/v1?label=dependencies&message=update&color=g) [![MIT](https://img.shields.io/badge/license-MIT-green)](https://github.com/Big-billed-shark/fineely-config/blob/main/LICENSE) [![Maven Central](https://img.shields.io/static/v1?label=Stars&logo=github&message=3&color=grey)](https://github.com/Big-billed-shark/fineely-config) [![Gitee](https://img.shields.io/static/v1?label=Stars&logo=gitee&message=1&color=grey)](https://gitee.com/kepler_16b/fineely-config) ## Pull Requests on Github By sending a pull request, you grant KeplerLei sufficient permissions to use and publish the work submitted under the KeplerLei license. ## Getting Started `fineely-config` is available at the Central `Maven` Repository. Maven users add this to your `POM`. ```xml com.fineely fineely-config 1.0.6 ``` Gradle users add this to your `build.gradle`. ```groovy implementation 'com.fineely:fineely-config:1.0.6' ``` ## Usage Basic usage of the `fineely-config` : add annotations `@EnableAutoConfigScan` ```java @EnableAutoConfigScan({"com.example"}) // configure the package path of the class @SpringBootApplication(scanBasePackages = {"com.example"}) public class WebApplication { public static void main(String[] args) { SpringApplication.run(WebApplication.class, args); } } ``` Implementing the `ConfigSupport` interface. Will automatically generate `get[class name]` and `update[class name]`. ```java package com.example; import com.fineelyframework.config.core.entity.ConfigSupport; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter @AllArgsConstructor @NoArgsConstructor public class SystemConfig implements ConfigSupport { private String code = "example"; // Currently, only basic data types are supported } ``` And an `spring data jpa` example `application.yml` configuration file: ```yaml spring: jpa: hibernate: ddl-auto: update fineely: config: datasource: jpa ``` And an `mybatis` example `application.yml` configuration file: ```yaml fineely: config: datasource: mybatis ``` But `mybatis` does not automatically generate tables, you can use third-party tools or execute SQL ```sql SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; CREATE TABLE IF NOT EXISTS `config` ( `CONFIG_ID` INT ( 11 ) NOT NULL AUTO_INCREMENT COMMENT 'CONFIG_ID', `CONFIG_CODE` VARCHAR ( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'Configuration encoding', `LAST_MODIFY_TIME` datetime DEFAULT NULL COMMENT 'Modification time', `CONFIG_VALUE` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT 'Configuration values', `CONFIG_CATEGORY` VARCHAR ( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'Configuration Category', PRIMARY KEY ( `CONFIG_ID` ) USING BTREE ) ENGINE = INNODB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8 ROW_FORMAT = DYNAMIC COMMENT = 'Basic Configuration Table'; SET FOREIGN_KEY_CHECKS = 1; ``` Access after project launch ```text GET http://localhost:port/rest/config/getSystemConfig POST http://localhost:port/rest/config/updateSystemConfig ``` ## Senior If you don't want to use `/rest/config/` as a prefix ```java // Can modify requestMapping @EnableConfigScan(basePackage = "***", requestMapping = "/rest/config/") ``` ```java // Used alone @Autowired private FineelyConfigService fineelyConfigService; public String get() { SystemConfig systemConfig = fineelyConfigService.get(new SystemConfig()); return systemConfig.getCode(); } public String update() { SystemConfig config = new SystemConfig(); config.setCode("1"); fineelyConfigService.update(config); return "ok"; } ``` ## Issue Tracking Issues, bugs, and feature requests should be submitted to [the issue tracker](https://github.com/Big-billed-shark/fineely-config/issues). Pull requests on GitHub are welcome, but please open a ticket in the issue tracker first, and mention the issue in the pull request.