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

打包的问题。如何把apollo-env.properties配置文件从core的jar包移到外面? #584

Closed
myfreeway opened this issue Apr 7, 2017 · 7 comments

Comments

@myfreeway
Copy link

操作的目的是一个porta配置多套环境的配置。
按照分布式部署指南,我修改scripts/build.sh的
dev_meta=http://dev-config:8080 fat_meta=http://fat-config:8080 uat_meta=http://uat-config:8080 pro_meta=http://pro-config:8080
最后发现这几个参数只被打进apollo-portal-0.6.2-dev.zip/apollo-portal-0.6.2.jar/lib/apollo-core-0.6.2.jar/apollo-env.properties。
我想在外部设置这几个参数的值,应该怎么操作呢?
目前尝试过的办法有以下几种,都无效。
把最终的apollo-env.properties放在
apollo-portal-8070-dev/config/apollo-env.properties
apollo-portal-8070-dev/apollo-env.properties
把配置项放到apollo-portal-8070-dev/config/application-dev.properties
都无效。
谢谢!

@nobodyiam
Copy link
Member

启动portal的时候通过-Ddev_meta=xxx可以传入的,可以修改portal的startup.sh中的JAVA_OPTS。

另外,把apollo-env.properties放在和apollo-portal-0.6.2.jar一个目录下不可以吗?

@myfreeway
Copy link
Author

把apollo-env.properties放在和apollo-portal-0.6.2.jar一个目录下,也不行。
经测试,发现【启动portal的时候通过-Ddev_meta=xxx可以传入的,可以修改portal的startup.sh中的JAVA_OPTS。】这样才可以。
感觉有点不合逻辑。我把application-dev.properties放到config目录里,可以覆盖common包的配置文件。资料也说config的配置文件优先级最高。但是不知道为什么core包的配置文件覆盖不了。

@nobodyiam
Copy link
Member

@myfreeway
Copy link
Author

呵呵,有可能是这行代码。common包怎么加载配置文件呢?他能覆盖jar包里的properties。

@nobodyiam
Copy link
Member

application-dev.properties是Spring加载的,可能有些不同,后面研究一下~

@nobodyiam
Copy link
Member

@myfreeway 研究了一下Spring boot加载配置文件的顺序,发现它会优先从working directory而非classpath加载配置文件,所以我也简单改了一下,可以实现你描述的效果了,参见Pull Request #607

@nobodyiam
Copy link
Member

0.7.0已经发布,此issue先关闭了~

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

2 participants