com.mdaniline:spring-autoproperties

Automatically implement interfaces using Value annotations

Лицензия

Лицензия

Категории

Категории

Auto Библиотеки уровня приложения Code Generators
Группа

Группа

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

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

spring-autoproperties
Последняя версия

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

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

com.mdaniline:spring-autoproperties
Automatically implement interfaces using Value annotations
Ссылка на сайт

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

https://github.com/mdaniline/spring-autoproperties
Система контроля версий

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

http://github.com/mdaniline/spring-autoproperties

Скачать spring-autoproperties

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

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

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
org.springframework : spring-core jar [3.2,)
org.springframework : spring-context jar [3.2,)
org.springframework : spring-beans jar [3.2,)
com.google.guava : guava jar [12,)

test (3)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.11
org.hamcrest : hamcrest-library jar 1.3
org.springframework : spring-test jar [3.2,)

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

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

spring-autoproperties

Build Status

A Spring plugin to automatically generate implementations of interfaces using @Value annotations. This is handy for organising multiple related properties into a single beans without needing to implement the bean itself.

Installation

Get the jar through Maven:

<dependency>
    <groupId>com.mdaniline</groupId>
    <artifactId>spring-autoproperties</artifactId>
    <version>1.0.1</version>
</dependency>

Dependencies

  • Java 1.6+
  • Spring 4.2+

Usage

  1. Annotate your application config bean with @EnableAutoProperties. You will need to specify the basePackages and/or basePackageClasses properties to configure which packages should be scanned.
  2. Create an interface which you want to proxy and annotate it with @AutoProperties. Every method should be in getter-style (non-void return value and no parameters) and annotated with @Value. For example:
@AutoProperties
public interface DatabaseSettings {

    @Value("${db.connectionString}")
    String getConnectionString();

    @Value("${db.username}")
    String getUsername();

    @Value("${db.password}")
    String getPassword();

    @Value("${db.pool.maxActive}")
    Integer getMaxActiveConnections();
}

Why would I bother?

You can now inject this single interface into your beans instead of a long, messy list of properties, e.g.

public class CustomDataSource {
    @Autowired
    public CustomDataSource(DatabaseSettings settings) {
        ...
    }
    ...
}

instead of

public class CustomDataSource {
    @Autowired
    public CustomDataSource(@Value("${db.connectionString}") String connectionString,
                            @Value("${db.username}") String username,
                            @Value("${db.password}") String password,
                            @Value("${db.pool.maxActive}") Integer maxActiveConnections) {
        ...
    }
    ...
}

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

Версия
1.0.0