Yandex QATools Properties Loader

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

License

License

Categories

Categories

Dex General Purpose Libraries Utility
GroupId

GroupId

ru.yandex.qatools.properties
ArtifactId

ArtifactId

properties-loader
Last Version

Last Version

1.6
Release Date

Release Date

Type

Type

jar
Description

Description

Yandex QATools Properties Loader
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Project Organization

Project Organization

Yandex

Download properties-loader

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
commons-beanutils : commons-beanutils jar 1.9.2

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-all jar 1.9.5

Project Modules

There are no modules declared in this project.

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.yandex.qatools.properties

Yandex QATools

Versions

Version
1.6
1.5
1.4
1.3