【发布时间】:2021-08-23 07:09:50
【问题描述】:
我正在为我们的项目开发一个通用库。这是一个 Maven 项目。现在它没有任何与Spring相关的依赖。
我在 Spring boot maven 项目中包含上述库作为依赖项。
当 Spring Boot 应用程序运行时,我需要从公共库中的 Spring Boot application.properties 中读取值。
假设我在 application.properties 中有环境键。
环境 = 舞台
我需要图书馆内环境的价值。
【问题讨论】:
-
我可能会建议创建一个可感知弹簧的包装器模块(可能是弹簧启动自动配置)。这样,您的库是独立于 spring 的,但可能以编程方式接受配置值,并且您的 spring 模块会自动获取 spring 属性。我认为你想要的最后一件事是让库本身直接从 application.properties 中读取。
标签: java spring spring-boot