Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

想转到springboot项目,怎么才能很好的支持yml格式的配置文件 #950

Closed
myfreeway opened this issue Feb 3, 2018 · 5 comments

Comments

@myfreeway
Copy link

现在已经用上了apollo,传统的ssi项目,使用properties格式的配置文件,key -value格式的。用的还不错。最近想用spring boot,但是发现spring boot喜欢用yml格式的配置文件。apollo怎么样才能很好的支持这种需求呢?

@nobodyiam
Copy link
Member

nobodyiam commented Feb 4, 2018

yml本质上和properties一样的,在spring boot代码中实际使用的配置项信息还是key-value格式。

比如

application.yml

spring:
  application:
    name: demo

application.properties

spring.application.name=demo

两者是一致的,代码中如果要获取该配置项,使用的还是${spring.application.name}

所以对Apollo而言,目前主要还是支持properties格式,后面或许可以考虑增强一下界面,支持yml录入,properties格式展示。

@arebya
Copy link

arebya commented Feb 7, 2018

yml和properties文件在绑定参数的时候存在有序和无序的区别,yml load的是LinkedHashMap,properties load的实际上是个HashTable,在某些场景下需要保证顺序,如druid-spring-boot-starter的issue issue1796

@nobodyiam
Copy link
Member

你说的是spring解析文件的过程,Apollo的配置不存在spring解析文件的过程,是直接放一个PropertySource进去的,机制上和spring自己解析是不同的,具体可以看下代码

不过程序也不能依赖于配置的顺序吧,这岂不是非常容易出问题了,跑的好好的,不小心调了个顺序就挂了?

@arebya
Copy link

arebya commented Feb 9, 2018

是的,主要是针对您上面“yml本质上和properties一样的,在spring boot代码中实际使用的配置项信息还是key-value格式。”这个来讨论的。

@nobodyiam
Copy link
Member

case先关闭了,如还有问题,可以提供更多信息,或进群交流。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants