Skip to content

Latest commit

 

History

History
39 lines (23 loc) · 1.17 KB

README.md

File metadata and controls

39 lines (23 loc) · 1.17 KB

nrich-spring

Maven Central

Overview

nrich-spring is a library containing add-ons on Spring framework. Currently, no additional configuration is needed, just adding the library as dependency is enough. This library contains ApplicationContextHolder util class that provides access to ApplicationContext in static context as well as YamlPropertySourceFactory that enables using yaml files with @PropertySource annotation.

Usage

If ApplicationContext is required in static context:

public class SomeComponentNotAutowiredBySpring {

    public void useContext() {
        ApplicationContext applicationContext = ApplicationContextHolder.getApplicationContext();

        // do something with application context
    }
}

If loading of yaml files through @PropertySource annotation is needed:

@PropertySource(value = "classpath:example.yml", factory = YamlPropertySourceFactory.class)
@Configuration(proxyBeanMethods = false)
public class ExampleConfiguration {

}