简体   繁体   English

如何从 POM.xml 读取 application.properties

[英]How to read application.properties from POM.xml

I'm not able to find out if it is possible to read any data in Spring's application.properties in the pom.xml file.我无法确定是否可以读取 pom.xml 文件中 Spring 的 application.properties 中的任何数据。

In my application-dev.properties file, I have an attribute:在我的application-dev.properties文件中,我有一个属性:

google.project.id = 123456789

In my application-test.properties file, I have an attribute:在我的application-test.properties文件中,我有一个属性:

google.project.id = 987654321

In my application.properties file, I have an attribute.在我的application.properties文件中,我有一个属性。 At one point I set it up for DEV at another time for TEST :有一次我为DEV设置它,另一次为TEST设置它:

spring.profiles.active=dev 

In my pom.xml file, I would like to read this project id according to the configuration in the spring.profiles.active attribute:在我的pom.xml文件中,我想根据 spring.profiles.active 属性中的配置读取这个项目 id:

<configuration>
  <projectId> PROJECT ID ???</projectId>
  <version>1</version>
</configuration>

Please, could someone help me?请问,有人可以帮我吗?

Thank you.谢谢你。

POM.xml is part of maven project build and has nothing to do with spring. POM.xml 是 maven 项目构建的一部分,与 spring 无关。

Spring framework has no idea about pom file. Spring 框架不知道 pom 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM