在没有Spring的情况下注入应用程序属性

在没有Spring的情况下注入应用程序属性,第1张

在没有Spring的情况下注入应用程序属性

我最终使用apache commons配置:

pom.xml:

<dependency>      <groupId>commons-configuration</groupId>      <artifactId>commons-configuration</artifactId>      <version>1.6</version>    </dependency>

src /…/ PropertiesLoader.java

PropertiesConfiguration config = new PropertiesConfiguration();config.load(PROPERTIES_FILENAME);config.getInt("someKey");

/src/main/resources/application.properties

someKey: 2

我不想将我的库变成Spring应用程序(我想要

@Value
注释,但没有应用程序上下文+
@Component
,多余的bean,多余的Spring生态系统/包,这在我的项目中没有意义)。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5561936.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-14
下一篇2022-12-14

发表评论

登录后才能评论

评论列表(0条)

    保存