Search code examples
javadependency-injectionannotations

An alternative to org.springframework.beans.factory.annotation.Value which is not Spring based


I am a Spring user and I'm quite fond of things like org.springframework.beans.factory.annotation.Value and dependency injection.

Unfortunately, for the project I'm working on, a requirement is not to use Spring. Sure, I can write a stupid class that loads the properties and has the respective getter methods for these properties. What I'm wondering about is whether there is an alternative more elegant and lightweight package which can inject these values from properties files into my variables for me. Something with nifty annotations like the above-mentioned.

I basically have to avoid the whole complexity of the Spring/Guice frameworks.

Thanks in advance!


Solution

  • I will answer my own question, as I ended up knocking up the code myself and putting it up on github.

    So, if anybody would ever need something like this, you can have a look at:

    https://github.com/carlspring/properties-injector

    I will try an push it to Maven Central as it's a Maven project.