Spring Value Annotation Processor

Annotation processor to extract all configuration properties injected through Spring @Value annotations

Лицензия

Лицензия

Группа

Группа

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

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

spring-value-annotation-processor
Последняя версия

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

0.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

Spring Value Annotation Processor
Annotation processor to extract all configuration properties injected through Spring @Value annotations
Ссылка на сайт

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

https://github.com/egoettelmann/spring-value-annotation-processor
Система контроля версий

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

https://github.com/egoettelmann/spring-value-annotation-processor

Скачать spring-value-annotation-processor

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

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

Зависимости

test (1)

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

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

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

Spring Value Annotation Processor

Maven Central CircleCI build (develop)

An annotation processor to extract all configuration properties injected through Spring @Value annotations.

It generates a spring-configuration-metadata.json conforming to the Configuration Metadata format defined by Spring Boot.

Goal of this project

Background

Most of the time, possible configuration properties for legacy Spring projects are maintained manually. Documentation is difficult to keep up to date and becomes easily outdated.

This annotation processor allows to automatically extract all configuration properties at build time. The generated file(s) can be used to:

  • add auto-completion of configuration files in your IDE
  • expose possible configuration properties through your app like Spring Boot Actuator does
  • analyze the project's dependencies on configuration properties
  • generate documentation

Generated metadata

For every class attribute annotated with @Value, the processor will generate:

  • the name of the configuration property used
  • the type of the attribute
  • the description taken from the JavaDoc defined on the attribute (if any)
  • the sourceType of the enclosing class
  • the defaultValue specified in the annotation (if any)

Additionally, the processor recognizes SPEL expressions and extracts properties out of them. In this case the type will not correspond to the property itself, but to the attribute's one. Currently, if multiple properties are used within the same expression, only the first one is extracted.

Usage

If using Maven, you can simply add the project as a provided dependency.

<dependency>
    <groupId>com.github.egoettelmann</groupId>
    <artifactId>spring-value-annotation-processor</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <scope>provided</scope>
</dependency>

If you are using the maven-compiler-plugin for your build, you will have to declare it in the annotationProcessorPaths. The plugin's configuration should look to something like the following:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <annotationProcessorPaths>
            <!-- in addition to any other annotation processor (like Lombok, etc.) -->
            <annotationProcessorPath>
                <groupId>com.github.egoettelmann</groupId>
                <artifactId>spring-value-annotation-processor</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </annotationProcessorPath>
        </annotationProcessorPaths>
    </configuration>
</plugin>

After executing mvn clean package, you can find the spring-configuration-metadata.json file under target/classes/META-INF/.

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

Версия
0.0.2
0.0.1