admin管理员组文章数量:1221259
I must switch from Eclipse to IntelliJ 2024.3.1.1 upon customer's request. They use jdk1.8.0_271, SprinBoot 2.6.14 and they have a lot of Maven profile, one per customer, in their parent pom.
By the way for each Maven profile there are one or more Spring profile and one or more .properties file with configuration about datasource, path ecc...
In my Eclipse IDE I usually run the application from the boot-dashboard referencing external .properties
file using the follow directive in JVM Option:
-Dspring.config.location=file:/path-to-properties-folder/, file:/path-to-file/application.properties
As you know the above directive overwrite the default Spring configuration. I also usually mix the default config adding some other file using spring.config.additional-location
instead of the one mentioned above.
The question is how can I do the same with IntelliJ? I have tryed to link a .properties
file this way:
(Ignore the JAVA 21 Version this is just an example)
I have tried using spring-boot:run
instead of spring-boot:start
, I have also used different way to achieve the file like:
-Dspring.config.location=file:/path-to-folder/ --> should read everything inside the folder
-Dspring.config.location=file:/path-to-file/application.properties
Both two inserted in VM Options field of Maven Run/Debug Configuration but it never worked. What's wrong?
I must switch from Eclipse to IntelliJ 2024.3.1.1 upon customer's request. They use jdk1.8.0_271, SprinBoot 2.6.14 and they have a lot of Maven profile, one per customer, in their parent pom.
By the way for each Maven profile there are one or more Spring profile and one or more .properties file with configuration about datasource, path ecc...
In my Eclipse IDE I usually run the application from the boot-dashboard referencing external .properties
file using the follow directive in JVM Option:
-Dspring.config.location=file:/path-to-properties-folder/, file:/path-to-file/application.properties
As you know the above directive overwrite the default Spring configuration. I also usually mix the default config adding some other file using spring.config.additional-location
instead of the one mentioned above.
The question is how can I do the same with IntelliJ? I have tryed to link a .properties
file this way:
(Ignore the JAVA 21 Version this is just an example)
I have tried using spring-boot:run
instead of spring-boot:start
, I have also used different way to achieve the file like:
-Dspring.config.location=file:/path-to-folder/ --> should read everything inside the folder
-Dspring.config.location=file:/path-to-file/application.properties
Both two inserted in VM Options field of Maven Run/Debug Configuration but it never worked. What's wrong?
Share Improve this question asked Feb 6 at 20:38 CoderJammerCoderJammer 7154 gold badges11 silver badges38 bronze badges 2- In your yml file, add spring: profiles: active: native. Create application-native.yml then define location of your configuration folder here.| spring: config: import: <your-config-folder> docs.spring.io/spring-boot/docs/2.6.14/reference/html/… – Syed Commented Feb 7 at 3:57
- thanks for your reply man but this is a workaround not the solution I'm looking for... and you read the wrong paragraph of the docs, the 2.3 is the right one. Read my answer below – CoderJammer Commented Feb 7 at 11:30
1 Answer
Reset to default 0Using the same directive in the Environment Varaible work like a sharm:
Hope helps.
本文标签: mavenIntelliJ CE run springboot App with external config fileStack Overflow
版权声明:本文标题:maven - IntelliJ CE run spring-boot App with external config file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739361305a2159831.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论