我的application.yml文件如下所示。如何将其转换为application.properties我正在尝试,但如何在同一文件中写入多个属性。它给了我重复的kery错误。
---
spring:
profiles: peer1
eureka:
instance:
hostname: peer1
client:
serviceUrl:
defaultZone: http://peer2/eureka/
---
spring:
profiles: peer2
eureka:
instance:
hostname: peer2
client:
serviceUrl:
defaultZone: http://peer1/eureka/
发布于 2020-07-29 12:12:39
IntelliJ和其他IDE提供了相同的插件。
对于eg- https://plugins.jetbrains.com/plugin/13804-convert-yaml-and-properties-file
安装插件,右键单击您的yaml或属性文件,并选择-“转换yaml和属性文件”。
发布于 2018-08-28 21:57:53
当使用属性文件时,您不能在同一文件中每个配置文件有多个“节”,这是一个仅在Yaml中可用的特性。您必须创建多个属性文件,每个配置文件一个,如下所述:https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-change-configuration-depending-on-the-environment
应用程序要对属性文件执行相同的操作,可以使用
-${.properties}指定特定于配置文件的值
您将有一个包含常用值的主配置文件,然后每个配置文件都有一个包含依赖于环境/配置文件的值的应用程序-${ application.properties }.properties文件。
最后,您必须在运行应用程序时将活动配置文件设置为系统属性,或者直接在主application.properties文件中设置活动配置文件,如下所述:https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-set-active-spring-profiles
发布于 2018-08-28 22:09:31
您将需要创建不同的文件,例如:
然后在application.properties中定义您的活动配置文件:
spring.profiles.active=dev
https://stackoverflow.com/questions/52059609
复制相似问题