properties-scanner

The project can easily read configuration files, read the configuration information to the entity class.

Лицензия

Лицензия

Группа

Группа

com.github.developframework
Идентификатор

Идентификатор

properties-scanner
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

properties-scanner
The project can easily read configuration files, read the configuration information to the entity class.
Ссылка на сайт

Ссылка на сайт

https://github.com/developframework/properties-scanner
Система контроля версий

Система контроля версий

https://github.com/developframework/properties-scanner

Скачать properties-scanner

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.developframework/properties-scanner/ -->
<dependency>
    <groupId>com.github.developframework</groupId>
    <artifactId>properties-scanner</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.developframework/properties-scanner/
implementation 'com.github.developframework:properties-scanner:1.0.0'
// https://jarcasting.com/artifacts/com.github.developframework/properties-scanner/
implementation ("com.github.developframework:properties-scanner:1.0.0")
'com.github.developframework:properties-scanner:jar:1.0.0'
<dependency org="com.github.developframework" name="properties-scanner" rev="1.0.0">
  <artifact name="properties-scanner" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.developframework', module='properties-scanner', version='1.0.0')
)
libraryDependencies += "com.github.developframework" % "properties-scanner" % "1.0.0"
[com.github.developframework/properties-scanner "1.0.0"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.projectlombok : lombok Необязательный jar 1.16.10
org.slf4j : slf4j-api jar 1.7.21

Модули Проекта

Данный проект не имеет модулей.

Properties-scanner

可以方便的读取配置文件,把配置信息读取到实体类。

注解解释

@ScanProperties 加在类上,用属性location标明读取的properties文件名,用属性prefix设定前缀。

@ScanProperty 可选注解,标注在字段上,可以用alias设定别名,ifMissingOfValue指定当配置不存在时的默认值。

范例:

test.properties

#configuration_a
configuration_a.param1=xxxxx
configuration_a.param2=

#configuration_b
configuration_b.param1=yyyyy
configuration_b.param2=200

ConfigurationA.java

import com.github.developframework.scanner.annotation.ScanProperties;
import com.github.developframework.scanner.annotation.ScanProperty;
import lombok.Data;

@Data
@ScanProperties(location = "test", prefix = "configuration_a")
public class ConfigurationA {

    private String param1;

    @ScanProperty(alias = "param2", ifMissingOfValue = "999")
    private int param2;
}

ConfigurationB.java

import com.github.developframework.scanner.annotation.ScanProperties;
import lombok.Data;

@Data
@ScanProperties(location = "test", prefix = "configuration_b")
public class ConfigurationB {

    private String param1;

    private int param2;
}

Main.java

import com.github.developframework.scanner.PropertiesBox;
import com.github.developframework.scanner.PropertiesScanner;

public class Main {

    public static void main(String[] args) {
        PropertiesScanner propertiesScanner = new PropertiesScanner();
        PropertiesBox box = propertiesScanner.scan(ConfigurationA.class, ConfigurationB.class);

        ConfigurationA configuration_a = box.get(ConfigurationA.class);
        ConfigurationB configuration_b = box.get(ConfigurationB.class);

        System.out.println(configuration_a.toString());
        System.out.println(configuration_b.toString());
    }
}

Версии библиотеки

Версия
1.0.0