grails - 使用 grails 3 中的外部配置覆盖 application.groovy 中的属性

标签 grails spring-boot grails-3.0

grails 3 中不再有 grails.config.locations 属性,现在 Grails 3 使用 Spring 的属性源概念,但是如何在 grails 3 中实现与之前相同的行为版本?假设我想使用外部配置文件覆盖 application.grovy 文件中的某些属性 property.to.be.overridden 。我该怎么做?

最佳答案

相当于grails.config.locations的是spring.config.location

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files

这是一个在从命令行启动 jar 时指定配置位置的示例(这些相同的参数可以在您的 ide 内部使用)

 java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties

此外,由于您提到想要覆盖属性,因此了解 Spring Boot 处理配置文件特定属性文件的方式很有用(也可以指定多个配置文件)

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-profile-specific-properties

关于grails - 使用 grails 3 中的外部配置覆盖 application.groovy 中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33420941/

相关文章:

grails - 如果已经在yml根目录中定义了Grails application.yml,则如何使用这些特定于环境的条目?

java - Spring 启动,JPA。存储库不是托管类型

java - Spring 启动 Controller 404

grails - 在GORM中对可为空的字段进行排序

plugins - Grails Maven依赖解析

grails - 在自定义的Grails环境中,如何在不重新启动的情况下将代码更改为自动更新

java - 如何在 Spring Boot 中从资源服务器中的 token 中提取声明

grails - Grails 3.0.10 GORM继承

tomcat - grails 3 tomcat war 网站网址上下文

grails 变更日志先决条件不执行任何操作