mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 18:48:20 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 83037baf10 | |||
| adf90a983b | |||
| 02d816cd8d | |||
| 5d5626bff2 | |||
| 363c1e7ed8 | |||
| 7884d49309 | |||
| b77e64e6e6 |
@@ -1,3 +1,10 @@
|
|||||||
|
```text
|
||||||
|
____ _____ ____ __ _
|
||||||
|
/ __/__ ____ __ __ / ___/__ ___ / _(_)__ ___ _________ _/ /_(_)__ ___
|
||||||
|
/ _// _ `(_-</ // / / /__/ _ \/ _ \/ _/ / _ `/ // / __/ _ `/ __/ / _ \/ _ \
|
||||||
|
/___/\_,_/___/\_, / \___/\___/_//_/_//_/\_, /\_,_/_/ \_,_/\__/_/\___/_//_/
|
||||||
|
/___/ /___/
|
||||||
|
```
|
||||||
|
|
||||||
README LANGUAGES [ [**English**](README.md) | [中文](README_CN.md) ]
|
README LANGUAGES [ [**English**](README.md) | [中文](README_CN.md) ]
|
||||||
|
|
||||||
@@ -17,17 +24,21 @@ Enjoy the ease of use with customizable formats for loading, reading, and updati
|
|||||||
|
|
||||||
## Features & Advantages
|
## Features & Advantages
|
||||||
|
|
||||||
- Class-based mechanism for initializing, loading, retrieving, and updating configuration files, ensuring convenience and efficiency.
|
Supported [YAML](impl/yaml), [JSON](impl/json), [HOCON](impl/hocon) and [SQL](impl/sql) based configuration files
|
||||||
|
format.
|
||||||
|
|
||||||
|
- Class-based mechanism for initializing, loading, retrieving, and updating configuration files, ensuring convenience
|
||||||
|
and efficiency.
|
||||||
- Supports manual serialization and deserialization of complex configurations.
|
- Supports manual serialization and deserialization of complex configurations.
|
||||||
- Offers multiple builder forms for rapid construction of `ConfigValue<?>` objects.
|
- Offers multiple builder forms for rapid construction of `ConfigValue<?>` objects.
|
||||||
- Enables specification of configuration paths, comments, and more via annotations.
|
- Enables specification of configuration paths, comments, and more via annotations.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
For a detailed development guide, [CLICK HERE](.doc/README.md).
|
|
||||||
|
|
||||||
For the latest JavaDoc release, [CLICK HERE](https://CarmJos.github.io/EasyConfiguration).
|
For the latest JavaDoc release, [CLICK HERE](https://CarmJos.github.io/EasyConfiguration).
|
||||||
|
|
||||||
|
For a detailed development guide, [CLICK HERE](.doc/README.md).
|
||||||
|
|
||||||
### Code Samples
|
### Code Samples
|
||||||
|
|
||||||
Check out some code demonstrations [HERE](demo/src/main/java/cc/carm/lib/configuration/demo/DatabaseConfiguration.java).
|
Check out some code demonstrations [HERE](demo/src/main/java/cc/carm/lib/configuration/demo/DatabaseConfiguration.java).
|
||||||
@@ -42,6 +53,7 @@ For more examples, see the [Development Guide](.doc/README.md).
|
|||||||
<summary>Remote Repository Configuration</summary>
|
<summary>Remote Repository Configuration</summary>
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
|
|
||||||
<project>
|
<project>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
||||||
@@ -69,6 +81,7 @@ For more examples, see the [Development Guide](.doc/README.md).
|
|||||||
<summary>Generic Native Dependency</summary>
|
<summary>Generic Native Dependency</summary>
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
|
|
||||||
<project>
|
<project>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Basic implementation part, requiring custom implementation of “Provider” and “Wrapper”. -->
|
<!-- Basic implementation part, requiring custom implementation of “Provider” and “Wrapper”. -->
|
||||||
@@ -160,7 +173,7 @@ Many thanks to Jetbrains for kindly providing a license for us to work on this a
|
|||||||
|
|
||||||
[](https://www.jetbrains.com/?from=https://github.com/ArtformGames/ResidenceList)
|
[](https://www.jetbrains.com/?from=https://github.com/ArtformGames/ResidenceList)
|
||||||
|
|
||||||
|
|
||||||
## Open Source License
|
## Open Source License
|
||||||
|
|
||||||
This project's source code is licensed under the [GNU LESSER GENERAL PUBLIC LICENSE](https://www.gnu.org/licenses/lgpl-3.0.html).
|
This project's source code is licensed under
|
||||||
|
the [GNU LESSER GENERAL PUBLIC LICENSE](https://www.gnu.org/licenses/lgpl-3.0.html).
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ README LANGUAGES [ [English](README.md) | [**中文**](README_CN.md) ]
|
|||||||
|
|
||||||
## 特性 & 优势
|
## 特性 & 优势
|
||||||
|
|
||||||
|
支持 [YAML](impl/yaml), [JSON](impl/json), [HOCON](impl/hocon) 和 [SQL](impl/sql) 等多种配置文件格式。
|
||||||
|
|
||||||
- 基于类的配置文件初始化、加载、获取与更新机制,方便快捷。
|
- 基于类的配置文件初始化、加载、获取与更新机制,方便快捷。
|
||||||
- 支持复杂配置的手动序列化、反序列化。
|
- 支持复杂配置的手动序列化、反序列化。
|
||||||
- 提供多种builder形式,快速构建 `ConfigValue<?>` 对象。
|
- 提供多种builder形式,快速构建 `ConfigValue<?>` 对象。
|
||||||
@@ -107,6 +109,20 @@ README LANGUAGES [ [English](README.md) | [**中文**](README_CN.md) ]
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-hocon</artifactId>
|
||||||
|
<version>[LATEST RELEASE]</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-sql</artifactId>
|
||||||
|
<version>[LATEST RELEASE]</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
```
|
```
|
||||||
@@ -151,6 +167,10 @@ dependencies {
|
|||||||
//需要注意的是,JSON不支持文件注释。
|
//需要注意的是,JSON不支持文件注释。
|
||||||
api "cc.carm.lib:easyconfiguration-json:[LATEST RELEASE]"
|
api "cc.carm.lib:easyconfiguration-json:[LATEST RELEASE]"
|
||||||
|
|
||||||
|
api "cc.carm.lib:easyconfiguration-hocon:[LATEST RELEASE]"
|
||||||
|
|
||||||
|
api "cc.carm.lib:easyconfiguration-sql:[LATEST RELEASE]"
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.9.0</version>
|
<version>3.9.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.9.0</version>
|
<version>3.9.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
# EasyConfiguration-HOCON
|
||||||
|
|
||||||
|
HOCON file-based implementation, compatible with all Java environments.
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
### Maven Dependency
|
||||||
|
|
||||||
|
```xml
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<repositories>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
|
||||||
|
<id>maven</id>
|
||||||
|
<name>Maven Central</name>
|
||||||
|
<url>https://repo1.maven.org/maven2</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<!-- Using GitHub dependencies for real-time updates, configuration required (recommended). -->
|
||||||
|
<id>EasyConfiguration</id>
|
||||||
|
<name>GitHub Packages</name>
|
||||||
|
<url>https://maven.pkg.github.com/CarmJos/EasyConfiguration</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
</repositories>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-hocon</artifactId>
|
||||||
|
<version>[LATEST RELEASE]</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gradle Dependency
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
repositories {
|
||||||
|
|
||||||
|
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
|
||||||
|
mavenCentral()
|
||||||
|
|
||||||
|
// Using GitHub dependencies for real-time updates, configuration required (recommended).
|
||||||
|
maven { url 'https://maven.pkg.github.com/CarmJos/EasyConfiguration' }
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
dependencies {
|
||||||
|
api "cc.carm.lib:easyconfiguration-hocon:[LATEST RELEASE]"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example file format
|
||||||
|
|
||||||
|
```hocon
|
||||||
|
class-value=1.0
|
||||||
|
# Inner Test
|
||||||
|
inner {
|
||||||
|
inner-value=72.0043567836829
|
||||||
|
}
|
||||||
|
sub {
|
||||||
|
that {
|
||||||
|
operators=[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
test {
|
||||||
|
# Section类型数据测试
|
||||||
|
user {
|
||||||
|
info {
|
||||||
|
uuid="8aba6166-1dc3-476d-8eb6-8957434c05ba"
|
||||||
|
}
|
||||||
|
name=Carm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
test-enum=DAYS
|
||||||
|
test-number=5555780951875134464
|
||||||
|
# Section类型数据测试
|
||||||
|
user {
|
||||||
|
info {
|
||||||
|
uuid="9ed3a8f3-ad2a-4a62-a720-5530f5d19b33"
|
||||||
|
}
|
||||||
|
name="9038c"
|
||||||
|
}
|
||||||
|
# [ID - UUID]对照表
|
||||||
|
#
|
||||||
|
# 用于测试Map类型的解析与序列化保存
|
||||||
|
users {
|
||||||
|
"1"="4bfe382e-7b9e-4dad-9314-d16ddeb99f34"
|
||||||
|
"2"="6e587a1e-361e-43da-99ba-9de44db198dc"
|
||||||
|
"3"=ce582c1c-d696-43d4-ab58-af40d000d656
|
||||||
|
"4"="37b7eb1f-86b9-41c7-afa3-9ac9c75fef2c"
|
||||||
|
"5"="2659c33a-3393-404d-960e-850fef3b23fd"
|
||||||
|
}
|
||||||
|
uuid-value="035e89e8-3fe8-45ed-a25d-eef0bbe8f73d"
|
||||||
|
version=1.0
|
||||||
|
|
||||||
|
```
|
||||||
+2
-1
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<version>3.9.0</version>
|
<version>3.9.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<properties>
|
<properties>
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
<version>1.4.3</version>
|
<version>1.4.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package online.flowerinsnow.test.easyconfiguration;
|
package online.flowerinsnow.test.easyconfiguration;
|
||||||
|
|
||||||
import cc.carm.lib.configuration.EasyConfiguration;
|
import cc.carm.lib.configuration.EasyConfiguration;
|
||||||
|
import cc.carm.lib.configuration.demo.tests.ConfigurationTest;
|
||||||
import cc.carm.lib.configuration.hocon.HOCONFileConfigProvider;
|
import cc.carm.lib.configuration.hocon.HOCONFileConfigProvider;
|
||||||
import online.flowerinsnow.test.easyconfiguration.config.SimpleConfig;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -11,12 +11,9 @@ public class HOCONTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onTest() {
|
public void onTest() {
|
||||||
HOCONFileConfigProvider provider = EasyConfiguration.from(new File("target/hocon.conf"));
|
HOCONFileConfigProvider provider = EasyConfiguration.from(new File("target/hocon.conf"));
|
||||||
provider.initialize(SimpleConfig.class);
|
|
||||||
// provider.initialize(DatabaseConfiguration.class);
|
|
||||||
|
|
||||||
System.out.println(SimpleConfig.TEST_INT.getNotNull());
|
ConfigurationTest.testDemo(provider);
|
||||||
SimpleConfig.TEST_INT.set((int) (Math.random() * 100 * 5));
|
ConfigurationTest.testInner(provider);
|
||||||
System.out.println(SimpleConfig.TEST_INT.getNotNull());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
provider.save();
|
provider.save();
|
||||||
|
|||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
package online.flowerinsnow.test.easyconfiguration.config;
|
|
||||||
|
|
||||||
import cc.carm.lib.configuration.core.Configuration;
|
|
||||||
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
|
||||||
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
|
|
||||||
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
|
||||||
|
|
||||||
public interface SimpleConfig extends Configuration {
|
|
||||||
@HeaderComment("测试字段 int")
|
|
||||||
ConfiguredValue<Integer> TEST_INT = ConfiguredValue.of(Integer.class, 15);
|
|
||||||
|
|
||||||
@HeaderComment("测试字段 List<String>")
|
|
||||||
ConfiguredList<String> TEST_LIST_STRING = ConfiguredList.of(String.class, "li", "li", "li1");
|
|
||||||
|
|
||||||
@HeaderComment("测试对象")
|
|
||||||
interface TestObject extends Configuration {
|
|
||||||
|
|
||||||
@HeaderComment("测试字段 Boolean")
|
|
||||||
ConfiguredValue<Boolean> TEST_BOOLEAN = ConfiguredValue.of(Boolean.class, true);
|
|
||||||
|
|
||||||
@HeaderComment("inner")
|
|
||||||
interface InnerObject extends Configuration {
|
|
||||||
@HeaderComment("测试字段")
|
|
||||||
public static final ConfiguredValue<Boolean> TEST_BOOLEAN_1 = ConfiguredValue.of(Boolean.class, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
# EasyConfiguration-JSON
|
||||||
|
|
||||||
|
JSON file-based implementation, compatible with all Java environments.
|
||||||
|
|
||||||
|
**Remember that JSON does not support file comments.**
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
### Maven Dependency
|
||||||
|
|
||||||
|
```xml
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<repositories>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
|
||||||
|
<id>maven</id>
|
||||||
|
<name>Maven Central</name>
|
||||||
|
<url>https://repo1.maven.org/maven2</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<!-- Using GitHub dependencies for real-time updates, configuration required (recommended). -->
|
||||||
|
<id>EasyConfiguration</id>
|
||||||
|
<name>GitHub Packages</name>
|
||||||
|
<url>https://maven.pkg.github.com/CarmJos/EasyConfiguration</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
</repositories>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-json</artifactId>
|
||||||
|
<version>[LATEST RELEASE]</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gradle Dependency
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
repositories {
|
||||||
|
|
||||||
|
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
|
||||||
|
mavenCentral()
|
||||||
|
|
||||||
|
// Using GitHub dependencies for real-time updates, configuration required (recommended).
|
||||||
|
maven { url 'https://maven.pkg.github.com/CarmJos/EasyConfiguration' }
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
dependencies {
|
||||||
|
api "cc.carm.lib:easyconfiguration-json:[LATEST RELEASE]"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example file format
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": 1.0,
|
||||||
|
"test-number": 3185496340759645184,
|
||||||
|
"test-enum": "DAYS",
|
||||||
|
"user": {
|
||||||
|
"name": "774b3",
|
||||||
|
"info": {
|
||||||
|
"uuid": "f890b050-d3c5-4a32-a8b0-8a421ec2d4cc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sub": {
|
||||||
|
"that": {
|
||||||
|
"operators": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uuid-value": "a20c2eb2-e36b-40d7-a1ba-57826e3588c2",
|
||||||
|
"users": {
|
||||||
|
"1": "561f5142-8d59-4e50-855d-18638f3cfca8",
|
||||||
|
"2": "629fadab-c625-4678-85d2-cc73cb4aa3b7",
|
||||||
|
"3": "e29d1fb8-d8bd-4c2a-8ac0-4aaee77196dc",
|
||||||
|
"4": "8ff8ab49-7c34-44c0-9edd-203a9d44f309",
|
||||||
|
"5": "3c09dbff-ca37-468a-8c47-e8e52f837a54"
|
||||||
|
},
|
||||||
|
"inner": {
|
||||||
|
"inner-value": 49.831712577873375
|
||||||
|
},
|
||||||
|
"class-value": 1.0,
|
||||||
|
"test": {
|
||||||
|
"user": {
|
||||||
|
"name": "Carm",
|
||||||
|
"info": {
|
||||||
|
"uuid": "c3881d54-3d77-46ca-b031-2962b8b89141"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.9.0</version>
|
<version>3.9.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
# EasyConfiguration-SQL
|
||||||
|
|
||||||
|
SQL database implementation, support for MySQL or MariaDB.
|
||||||
|
|
||||||
|
## Table schema
|
||||||
|
```mysql
|
||||||
|
CREATE TABLE IF NOT EXISTS conf
|
||||||
|
(
|
||||||
|
`namespace` VARCHAR(32) NOT NULL, # 命名空间 (代表其属于谁,类似于单个配置文件地址的概念)
|
||||||
|
`path` VARCHAR(96) NOT NULL, # 配置路径 (ConfigPath)
|
||||||
|
`type` TINYINT UNSIGNED NOT NULL DEFAULT 0, # 数据类型 (Integer/Byte/List/Map/...)
|
||||||
|
`value` MEDIUMTEXT, # 配置项的值 (可能为JSON格式)
|
||||||
|
`inline_comments` TEXT, # 行内注释
|
||||||
|
`header_comments` MEDIUMTEXT, # 顶部注释
|
||||||
|
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, # 创建时间
|
||||||
|
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`namespace`, `path`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
### Maven Dependency
|
||||||
|
|
||||||
|
```xml
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<repositories>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
|
||||||
|
<id>maven</id>
|
||||||
|
<name>Maven Central</name>
|
||||||
|
<url>https://repo1.maven.org/maven2</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<!-- Using GitHub dependencies for real-time updates, configuration required (recommended). -->
|
||||||
|
<id>EasyConfiguration</id>
|
||||||
|
<name>GitHub Packages</name>
|
||||||
|
<url>https://maven.pkg.github.com/CarmJos/EasyConfiguration</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
</repositories>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-sql</artifactId>
|
||||||
|
<version>[LATEST RELEASE]</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gradle Dependency
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
repositories {
|
||||||
|
|
||||||
|
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
|
||||||
|
mavenCentral()
|
||||||
|
|
||||||
|
// Using GitHub dependencies for real-time updates, configuration required (recommended).
|
||||||
|
maven { url 'https://maven.pkg.github.com/CarmJos/EasyConfiguration' }
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
dependencies {
|
||||||
|
api "cc.carm.lib:easyconfiguration-sql:[LATEST RELEASE]"
|
||||||
|
}
|
||||||
|
```
|
||||||
+26
-6
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.9.0</version>
|
<version>3.9.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@@ -36,15 +36,14 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easysql-beecp</artifactId>
|
<artifactId>easysql-api</artifactId>
|
||||||
<version>0.4.7</version>
|
<version>0.4.7</version>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>easysql-beecp</artifactId>
|
||||||
<version>2.1.210</version>
|
<version>0.4.7</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -78,4 +77,25 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -28,13 +28,9 @@ public class SQLConfigTest {
|
|||||||
ConfigurationTest.testDemo(provider);
|
ConfigurationTest.testDemo(provider);
|
||||||
ConfigurationTest.testInner(provider);
|
ConfigurationTest.testInner(provider);
|
||||||
|
|
||||||
System.out.println("----------------------------------------------------");
|
|
||||||
provider.getConfiguration().getValues(true).forEach((k, v) -> System.out.println(k + ": " + v));
|
|
||||||
System.out.println("----------------------------------------------------");
|
|
||||||
provider.getConfiguration().getValues(false).forEach((k, v) -> System.out.println(k + ": " + v));
|
|
||||||
System.out.println("----------------------------------------------------");
|
|
||||||
|
|
||||||
ConfigurationTest.save(provider);
|
ConfigurationTest.save(provider);
|
||||||
|
|
||||||
|
EasySQL.shutdownManager(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS conf
|
|
||||||
(
|
|
||||||
`namespace` VARCHAR(32) NOT NULL, # 命名空间 (代表其属于谁,类似于单个配置文件地址的概念)
|
|
||||||
`path` VARCHAR(96) NOT NULL, # 配置路径 (ConfigPath)
|
|
||||||
`type` TINYINT UNSIGNED NOT NULL DEFAULT 0, # 数据类型 (Integer/Byte/List/Map/...)
|
|
||||||
`value` MEDIUMTEXT, # 配置项的值 (可能为JSON格式)
|
|
||||||
`inline_comments` TEXT, # 行内注释
|
|
||||||
`header_comments` MEDIUMTEXT, # 顶部注释
|
|
||||||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, # 创建时间
|
|
||||||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`namespace`, `path`)
|
|
||||||
) ENGINE = InnoDB
|
|
||||||
DEFAULT CHARSET = utf8mb4;
|
|
||||||
|
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
# EasyConfiguration-YAML
|
||||||
|
|
||||||
|
YAML file-based implementation, compatible with all Java environments.
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
### Maven Dependency
|
||||||
|
|
||||||
|
```xml
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<repositories>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
|
||||||
|
<id>maven</id>
|
||||||
|
<name>Maven Central</name>
|
||||||
|
<url>https://repo1.maven.org/maven2</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<!-- Using GitHub dependencies for real-time updates, configuration required (recommended). -->
|
||||||
|
<id>EasyConfiguration</id>
|
||||||
|
<name>GitHub Packages</name>
|
||||||
|
<url>https://maven.pkg.github.com/CarmJos/EasyConfiguration</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
</repositories>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easyconfiguration-yaml</artifactId>
|
||||||
|
<version>[LATEST RELEASE]</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gradle Dependency
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
repositories {
|
||||||
|
|
||||||
|
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
|
||||||
|
mavenCentral()
|
||||||
|
|
||||||
|
// Using GitHub dependencies for real-time updates, configuration required (recommended).
|
||||||
|
maven { url 'https://maven.pkg.github.com/CarmJos/EasyConfiguration' }
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
dependencies {
|
||||||
|
api "cc.carm.lib:easyconfiguration-yaml:[LATEST RELEASE]"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example file format
|
||||||
|
```yaml
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
|
test-save: false
|
||||||
|
|
||||||
|
test-number: 6161926779561752576
|
||||||
|
|
||||||
|
test-enum: DAYS
|
||||||
|
|
||||||
|
# Section类型数据测试
|
||||||
|
user: # Section数据也支持InlineComment注释
|
||||||
|
name: '35882'
|
||||||
|
info:
|
||||||
|
uuid: 554b79f1-7c39-4960-82d1-5514c9734417
|
||||||
|
|
||||||
|
uuid-value: 9a86663e-2fc7-4851-a423-c7e5d8e94a47 # This is an inline comment
|
||||||
|
|
||||||
|
sub:
|
||||||
|
that:
|
||||||
|
operators: []
|
||||||
|
|
||||||
|
# [ID - UUID]对照表
|
||||||
|
|
||||||
|
# 用于测试Map类型的解析与序列化保存
|
||||||
|
users:
|
||||||
|
'1': 1c055bdd-c9d1-4931-8270-3d162247f38a
|
||||||
|
'2': 934e2b05-2417-424e-80fd-fe58c6725837
|
||||||
|
'3': 442949a2-8345-4210-a87b-593d7168980e
|
||||||
|
'4': 5c015453-4b5b-42e3-ad87-b9498f2dfeab
|
||||||
|
'5': 8f9640e7-0fbd-4f73-b737-f0b707215e71
|
||||||
|
|
||||||
|
# Inner Test
|
||||||
|
inner:
|
||||||
|
inner-value: 51.223503560658166
|
||||||
|
|
||||||
|
class-value: 1.0
|
||||||
|
|
||||||
|
test:
|
||||||
|
# Section类型数据测试
|
||||||
|
user: # Section数据也支持InlineComment注释
|
||||||
|
name: Carm
|
||||||
|
info:
|
||||||
|
uuid: 3d1ef2a0-a38b-44f3-b15f-8e3b22cb8cc6
|
||||||
|
|
||||||
|
# 以下内容用于测试序列化
|
||||||
|
model-test:
|
||||||
|
some-model:
|
||||||
|
==: SomeModel
|
||||||
|
num: 855
|
||||||
|
name: 4f6b7
|
||||||
|
any-model:
|
||||||
|
==: AnyModel
|
||||||
|
name: 63d05
|
||||||
|
state: false
|
||||||
|
models:
|
||||||
|
- name: 481f3
|
||||||
|
state: true
|
||||||
|
- name: fcf3e
|
||||||
|
state: false
|
||||||
|
- name: '14e50'
|
||||||
|
state: false
|
||||||
|
model-map:
|
||||||
|
a:
|
||||||
|
name: 1fb9b
|
||||||
|
state: false
|
||||||
|
b:
|
||||||
|
name: 5486f
|
||||||
|
state: false
|
||||||
|
```
|
||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>3.9.0</version>
|
<version>3.9.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>easyconfiguration-parent</artifactId>
|
<artifactId>easyconfiguration-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>3.9.0</version>
|
<version>3.9.1</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>demo</module>
|
<module>demo</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user