Skip to content

Big-billed-shark/fineely-config

Repository files navigation

A Lightweight System Configuration Framework

Maven Central CSDN Libraries.io dependency status for GitHub repo MIT Maven Central Gitee

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.

<dependency>
    <groupId>com.fineely</groupId>
    <artifactId>fineely-config</artifactId>
    <version>1.0.6</version>
</dependency>

Gradle users add this to your build.gradle.

implementation 'com.fineely:fineely-config:1.0.6'

Usage

Basic usage of the fineely-config :

add annotations @EnableAutoConfigScan

@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].

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:

spring:
  jpa:
    hibernate:
      ddl-auto: update
fineely:
  config:
    datasource: jpa

And an mybatis example application.yml configuration file:

fineely:
  config:
    datasource: mybatis

But mybatis does not automatically generate tables, you can use third-party tools or execute 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

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

// Can modify requestMapping 
@EnableConfigScan(basePackage = "***", requestMapping = "/rest/config/")
// 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.

Pull requests on GitHub are welcome, but please open a ticket in the issue tracker first, and mention the issue in the pull request.

About

A Lightweight System Configuration Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages