基于Java注釋注入配置屬性:ADP4J
ADP4J是一個Java注釋驅動的配置屬性注入類庫。它可以讓你在項目中使用注釋以聲明的方式注入配置屬性。
配置屬性支持以下各種來源:
- System properties passed to JVM
- Properties files
- Resource bundles
- 數據庫
public class Bean { @SystemProperty("threshold") private int threshold; @Property(source = "myProperties.properties", key = "bean.name") private String beanName; //getters and setters omitted }
//Instantiate your object Bean bean = new Bean(); //Instantiate ADP4J configurator Configurator configurator = new ConfiguratorBuilder().build(); //Configure your object configurator.configure(bean);
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!