Groovy中的Spring引导外部配置
如何让Spring引导加载Groovy的外部属性? 需要类似于java机制的东西(参考资料中的application.properties和带有@Value注释的ConfigBean) 当尝试使用与java相同的机制时,我不知道如何注释ConfigBeanGroovy中的Spring引导外部配置,groovy,spring-boot,Groovy,Spring Boot,如何让Spring引导加载Groovy的外部属性? 需要类似于java机制的东西(参考资料中的application.properties和带有@Value注释的ConfigBean) 当尝试使用与java相同的机制时,我不知道如何注释ConfigBean @Component public class ConfigBean { @Value("${seleniumAddress}") private String seleniumAddress; ... 然后在applica
@Component
public class ConfigBean {
@Value("${seleniumAddress}")
private String seleniumAddress; ...
然后在application.properties中
seleniumAddress=http://localhost:4444/wd/hub
但是使用groovy,我不能用@Value(${seleniumAddress})
它抛出一个错误,抱怨“${}”——这是groovy中的一个特殊序列。
那么我应该在这里使用什么机制呢
谢谢如果您在Groovy中使用“${}”作为Spring占位符,您必须确保它是一个字符串(而不是GString):即使用“${}”(单引号)。也许您可以用一个(代码)来详细说明例如,我过去在POGOs fine中使用了@Value
和@ConfigProperties
注释。与java方式不同的是,没有注释