Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A lightweight and extensible library to resolve application properties from various external sources.

License

NotificationsYou must be signed in to change notification settings

joel-jeremy/externalized-properties

Repository files navigation

LicenseGradle BuildCodeQLMaven CentralCoverage StatusQuality Gate StatusMaintainability RatingReliability RatingSecurity RatingVulnerabilitiesCoverageDiscord

A lightweight and extensible library to resolve application properties from various external sources.

Like the project?

Please consider giving the repository a ⭐. It means a lot! Thank you :)

Externalized Properties was inspired by theThe Twelve Factor Methodology's sectionIII. Config.

The goal of this library is to make it easy for applications to implement configuration best practices by providing easy-to-use APIs as well as providing the flexibility to choose where to store their configurations/properties.

🛠️ Installation

Gradle

implementation"io.github.joel-jeremy.externalized-properties:externalized-properties-core:${version}"// Optional/additional resolversimplementation"io.github.joel-jeremy.externalized-properties:externalized-properties-database:${version}"implementation"io.github.joel-jeremy.externalized-properties:externalized-properties-git:${version}"

Maven

<dependency>  <groupId>io.github.joel-jeremy.externalized-properties</groupId>  <artifactId>externalized-properties-core</artifactId>  <version>${version}</version></dependency><!-- Optional/additional resolvers--><dependency>  <groupId>io.github.joel-jeremy.externalized-properties</groupId>  <artifactId>externalized-properties-database</artifactId>  <version>${version}</version></dependency><dependency>  <groupId>io.github.joel-jeremy.externalized-properties</groupId>  <artifactId>externalized-properties-git</artifactId>  <version>${version}</version></dependency>

🧩 Java 9 Module Names

Externalized Properties jars are published with Automatic-Module-Name manifest attribute:

  • Core -io.github.joeljeremy.externalizedproperties.core
  • Database Resolver -io.github.joeljeremy.externalizedproperties.database
  • Git Resolver -io.github.joeljeremy.externalizedproperties.git

Module authors can use above module names in their module-info.java:

modulefoo.bar {requiresio.github.joeljeremy.externalizedproperties.core;requiresio.github.joeljeremy.externalizedproperties.database;requiresio.github.joeljeremy.externalizedproperties.git;}

🌟 Features

Externalized Properties takes full advantage of Java'sDynamic Proxies (Why Dynamic Proxies?).

✔️ Property Resolution

✔️ Conversion

✔️ Variable Expansion

✔️ Processing

✔️ Profiles

✔️ Ordinal Components

🏎️ Quick Start

Properties are mapped to proxy interface methods by using the@ExternalizedProperty annotation.

(For more advanced scenarios, please see the feature documentations.)

Given an interface:

publicinterfaceApplicationProperties {@ExternalizedProperty("java.home")StringjavaHome();@ExternalizedProperty("encrypted.property")@Decrypt("MyDecryptor")StringencryptedProperty();@ExternalizedProperty("java.version")intjavaVersion();}

We can initialize and start resolving external configurations/properties by:

publicstaticvoidmain(String[]args) {// 1. Configure and build the ExternalizedProperties instance.ExternalizedPropertiesexternalizedProperties =buildExternalizedProperties();// 2. Initialize a proxy using the ExternalizedProperties.ApplicationPropertiesprops =externalizedProperties.initialize(ApplicationProperties.class);// 3. Resolve the properties.StringjavaHome =props.javaHome();StringencryptedProperty =props.encryptedProperty();intjavaVersion =props.javaVersion();}privatestaticExternalizedPropertiesbuildExternalizedProperties() {returnExternalizedProperties.builder()      .defaults()       .resolvers(...)      .processors(...)      .converters(...)       .build();}

🧪 Samples

More sample can be found here:https://github.com/joel-jeremy/externalized-properties-samples


SonarQube Cloud

About

A lightweight and extensible library to resolve application properties from various external sources.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp