读取POM.xml中的application.properties。

huangapple go评论91阅读模式
英文:

How to read application.properties from POM.xml

问题

我无法确定是否可以在pom.xml文件中读取Spring的application.properties中的任何数据。

在我的application-dev.properties文件中,我有一个属性:

google.project.id = 123456789

在我的application-test.properties文件中,我有一个属性:

google.project.id = 987654321

在我的application.properties文件中,我有一个属性。在某一时刻,我将其设置为DEV,在另一时刻设置为TEST

spring.profiles.active=dev

在我的pom.xml文件中,我想根据spring.profiles.active属性的配置来读取此项目ID:

<configuration>
  <projectId>项目ID ???</projectId>
  <version>1</version>
</configuration>

请问有人能帮我吗?

谢谢。

英文:

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.

In my application-dev.properties file, I have an attribute:

google.project.id = 123456789

In my application-test.properties file, I have an attribute:

google.project.id = 987654321

In my application.properties file, I have an attribute. At one point I set it up for DEV at another time for 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:

&lt;configuration&gt;
  &lt;projectId&gt; PROJECT ID ???&lt;/projectId&gt;
  &lt;version&gt;1&lt;/version&gt;
&lt;/configuration&gt;

Please, could someone help me?

Thank you.

答案1

得分: 3

POM.xml是Maven项目构建的一部分,与Spring无关。

Spring框架不了解pom文件。

英文:

POM.xml is part of maven project build and has nothing to do with spring.

Spring framework has no idea about pom file.

huangapple
  • 本文由 发表于 2020年8月13日 09:21:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/63386770.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定