Commons Properties

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

Лицензия

Лицензия

Группа

Группа

ru.qatools.commons
Идентификатор

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

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

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

2.0.RC6
Дата

Дата

Тип

Тип

jar
Описание

Описание

Commons Properties
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Организация-разработчик

Организация-разработчик

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

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

https://github.com/qatools/properties

Скачать properties

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

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

Зависимости

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.hamcrest : hamcrest-all jar 1.3

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

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

QATools Properties

release Maven Central build covarage

This library provides convenient way to work with properties. It can handle property-files on hard drive, in classpath or get values from system properties.

Deprecation notice

This library is not actively maintained, so please look at the same libs

Getting started

To add Properties to your Java project, put the following in the dependencies section of your POM:

Latest stable version:

<dependency>
    <groupId>ru.qatools.commons</groupId>
    <artifactId>properties</artifactId>
    <version>${LATEST_VERSION}</version>
</dependency>

Now you are ready to describe you configuration:

public interface MyConfig {

    @Property("proxy.port")
    int getPort();

    @Property("proxy.host")
    String getHost();

}

Then you need to populate the configuration:

MyConfig config = PropertyLoader.newInstance()
        .populate(MyConfig.class);

By default values proxy.port and proxy.host will be read from system properties. If you want to read properties from file you can use @Resource annotation:

@Resource.Classpath("proxy.properties")
public interface MyConfig {

    @Property("proxy.port")
    int getPort();

    @Property("proxy.host")
    String getHost();

}

There is a few available options:

  • @Resource.Classpath finds properties file by given name in your classpath.
  • @Resource.File finds properties file by given file path.

Put in your resources directory (mainly it src/main/resources) file proxy.properties

proxy.host=proxy.yandex.ru
proxy.port=3133

It's easy to override value from system properties. E.g. when you run your code with

-Dproxy.host=ya.ru

it overrides the default value in properties file.

ru.qatools.commons

QA Tools

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

Версия
2.0.RC6
2.0.RC5
2.0.RC4
2.0.RC3
2.0.RC2
2.0.RC1