-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
spring boot的application.properties配置可以放在apollo上么? #577
Comments
可以的,apollo注入配置的原理和spring cloud config一样的。参考Java客户端使用指南即可。 补充一点,目前注入的配置需要时properties格式,yml格式还不支持。 |
谢谢,在使用过程中还碰到一些问题想问 我想可能是不是我build的时候出的问题,因为在win环境开发,我把build.sh改成了build.bat,内容如下 :: apollo portal db info :: meta server url set META_SERVERS_OPTS="-Ddev_meta=%dev_meta% -Dfat_meta=%fat_meta% -Duat_meta=%uat_meta% -Dpro_meta=%pro_meta%" :: # =============== Please do not modify the following content =============== # rem package config-service and admin-service call mvn clean package -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=dev -Dspring_datasource_url=%apollo_config_db_url% -Dspring_datasource_username=%apollo_config_db_username% -Dspring_datasource_password=%apollo_config_db_password% echo "==== building config-service and admin-service finished ====" call mvn clean package -DskipTests -pl apollo-portal -am -Dapollo_profile=dev -Dspring_datasource_url=%apollo_portal_db_url% -Dspring_datasource_username=%apollo_portal_db_username% -Dspring_datasource_password=%apollo_portal_db_password% %META_SERVERS_OPTS% echo "==== building portal finished ====" call mvn clean install -DskipTests -pl apollo-client -am %META_SERVERS_OPTS% echo "==== building client finished ====" 看起来问题似乎出在set META_SERVERS_OPTS上?这里应该怎么改? |
看上去是脚本有点问题。。你如果打开apollo-core.jar里面的apollo-env.properties就知道了。 建议还是装一个Git Bash,然后跑build.sh吧。 |
谢谢回答,我用git bash build后,在eclipse里通过vm参数 |
build.sh里面有数据库配置的,你照着做就没问题啊。这部分配置实际上是会替换apollo-common下的application-dev.properties,你打完包看一下就明白了。 vm参数没有加载到的问题,这个可以在启动过程中看一下进程参数,如Linux下是 |
谢谢,已经解决了,我build.sh里配置的问题。 |
数据库配置是放在application-dev.properties,和application.yml是一个道理。build的时候传入参数最终就是写入了application-dev.properties。至于为啥不直接写在文件中很好理解吧,一个是因为每个环境不一样,一个是开源代码不能写啊。 eureka的配置因为会动态调整的,所以文件只能是一个fallback,最终还是要以数据库为准的。 |
十分感谢~ |
application.properties中使用,如:spring.datasource.url: ${someKeyFromApollo:someDefaultValue} 这是要重新启动实例才能加载吗? |
还有,有没有spring boot 使用apollo的详细点的例子呢? |
spring placeholder在运行时重新注入有几种方式
|
原来spring cloud的工程application.properties(yml)是通过cloud config server加载的,apollo能这样加载cloud的配置么?比如eureka,feign,ribbon的一些配置
The text was updated successfully, but these errors were encountered: