Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Groovy中的Spring引导外部配置_Groovy_Spring Boot - Fatal编程技术网

Groovy中的Spring引导外部配置

Groovy中的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

如何让Spring引导加载Groovy的外部属性? 需要类似于java机制的东西(参考资料中的application.properties和带有@Value注释的ConfigBean)

当尝试使用与java相同的机制时,我不知道如何注释ConfigBean

@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方式不同的是,没有注释