https://github.com/chrimle/spring-boot-static-property-injector

Inject Spring Boot Properties into static fields!

https://github.com/chrimle/spring-boot-static-property-injector

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.8%) to scientific vocabulary

Keywords

spring spring-boot spring-boot-3 spring-boot-starter

Keywords from Contributors

archival projection code-generation java-record interactive sequences generic observability autograding hacking
Last synced: 5 months ago · JSON representation

Repository

Inject Spring Boot Properties into static fields!

Basic Info
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 2
Topics
spring spring-boot spring-boot-3 spring-boot-starter
Created 9 months ago · Last pushed 7 months ago
Metadata Files
Readme Funding License Codeowners

README.md

Spring Boot Static Property Injector

Java CI with Maven Maven Package pages-build-deployment

If you find this project useful, please ⭐ Star ⭐ it and share it with others! This is the best way to show appreciation for this project - Thank you! ❤️

Purpose

Load Spring Boot properties (as SpEL and/or Spring Property Placeholders e.g. @Value-annotation) to static fields!

JavaDoc

The official JavaDoc hosted on javadoc.io.

Example

The following is a simple example of how this library can be used.

1. Import Dependency

xml <dependency> <groupId>io.github.chrimle</groupId> <artifactId>spring-boot-static-property-injector</artifactId> <version>0.1.1</version> </dependency>

[!NOTE] This artifact is hosted on - Maven Central Repository - GitHub Packages

2. Include StaticValueInjector Bean

```java import io.github.chrimle.sbspi.StaticValueInjector; import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackageClasses = StaticValueInjector.class) class ExampleSpringBootApplication {} ```

3. Configure Bean Class Scanning using sbspi.basePackage

properties sbspi.basePackage=your.example.app.subpackage

4. Annotate Fields with @StaticValue

```java import io.github.chrimle.sbspi.StaticValue;

public class Example {

// This field MAY remain null if the property is not set. @StaticValue("${myapp.custom.example-nullable-field}") private static String EXAMPLENULLABLEFIELD;

// This field MAY be set to "someDefaultValue" if the property is not set. @StaticValue("${myapp.custom.example-default-field:someDefaultValue}") private static String EXAMPLEDEFAULTFIELD;

} ```

5. If You encounter any issues

  1. For unexpected issues, a StaticValueInjectorException will be thrown with a description of what went wrong.
  2. In case of fields not being set as expected, review the sbspi.basePackage-property and the package name of the relevant class.
  3. Enable DEBUG logs for io.github.chrimle.sbspi to see which fields have been processed.
  4. Open a GitHub issue describing the issue and include the findings from these steps.

Road Map

Plan for the 1.0.0 release.

MAJOR

  • TBD...

MINOR

  • Support annotating static method arguments with @StaticValue
  • Support property prefixes on class-level
    • Useful when annotating multiple fields with long common property prefixes.
  • Improve DEBUG logs by masking potential secrets
    • Add isSecret-property to the @StaticValue annotation to mask property values in logs.

PATCH

  • Extend Test Suite
    • Test more rigorously
    • String
    • Integer
    • Boolean

Change Log

0.1.1

  • Updated JavaDocs
    • StaticValueInjectorException

0.1.0

  • Introduced @StaticValue
  • Introduced StaticValueInjector
  • Added Support for SpEL
  • Added Support for Property Placeholders
  • Published to GitHub Packages
  • Published to Maven Central Repository
  • Deployed GitHub Pages
  • Deployed JavaDoc

Owner

  • Name: Christopher Molin
  • Login: Chrimle
  • Kind: user
  • Location: Gothenburg
  • Company: Chrimle.com

Software Engineer

GitHub Events

Total
  • Release event: 3
  • Watch event: 1
  • Delete event: 17
  • Public event: 1
  • Push event: 26
  • Pull request review event: 4
  • Pull request event: 39
  • Create event: 24
Last Year
  • Release event: 3
  • Watch event: 1
  • Delete event: 17
  • Public event: 1
  • Push event: 26
  • Pull request review event: 4
  • Pull request event: 39
  • Create event: 24

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 14
  • Total Committers: 2
  • Avg Commits per committer: 7.0
  • Development Distribution Score (DDS): 0.071
Past Year
  • Commits: 14
  • Committers: 2
  • Avg Commits per committer: 7.0
  • Development Distribution Score (DDS): 0.071
Top Committers
Name Email Commits
Christopher Molin 2****e 13
dependabot[bot] 4****] 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 0
  • Total pull requests: 17
  • Average time to close issues: N/A
  • Average time to close pull requests: about 1 hour
  • Total issue authors: 0
  • Total pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.06
  • Merged pull requests: 13
  • Bot issues: 0
  • Bot pull requests: 4
Past Year
  • Issues: 0
  • Pull requests: 17
  • Average time to close issues: N/A
  • Average time to close pull requests: about 1 hour
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.06
  • Merged pull requests: 13
  • Bot issues: 0
  • Bot pull requests: 4
Top Authors
Issue Authors
  • Chrimle (1)
Pull Request Authors
  • Chrimle (29)
  • dependabot[bot] (11)
Top Labels
Issue Labels
test (1)
Pull Request Labels
meta (14) PATCH (11) dependencies (11) java (9) doc (7) MINOR (4) javadoc (3) refactor (2) test (1) feat (1)

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
repo1.maven.org: io.github.chrimle:spring-boot-static-property-injector

Inject Spring-Boot properties to static contexts.

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Dependent packages count: 48.6%
Average: 51.3%
Forks count: 59.0%
Stargazers count: 63.4%
Last synced: 6 months ago

Dependencies

.github/workflows/maven-publish.yml actions
  • actions/checkout v4 composite
  • actions/setup-java v4 composite
.github/workflows/maven.yml actions
  • actions/checkout v4 composite
  • actions/setup-java v4 composite
.github/workflows/pullRequestAudit.yml actions
  • actions/github-script v6 composite
pom.xml maven
  • org.springframework.boot:spring-boot-starter 3.5.0
  • org.springframework.boot:spring-boot-starter-test 3.5.0 test