Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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
如何在Spring中将属性文件中的值传递给字段的自定义注释_Spring - Fatal编程技术网

如何在Spring中将属性文件中的值传递给字段的自定义注释

如何在Spring中将属性文件中的值传递给字段的自定义注释,spring,Spring,我正在使用Spring4 我创建了一个自定义注释,如 @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface MyElement { HTML_TAG htmlTag() default HTML_TAG.INPUT_TEXT; FindBy findBy() default FindBy.NAME; String valueToFind() default "

我正在使用Spring4

我创建了一个自定义注释,如

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyElement {

    HTML_TAG htmlTag() default HTML_TAG.INPUT_TEXT;

    FindBy findBy() default FindBy.NAME;

    String valueToFind() default "";

}
现在,在我的班级里,有了
@组件
,我可以像

@Component
@PropertySource(value = "config/${environment}/environment.properties",     ignoreResourceNotFound = false)
public class MasterCardConnectPage extends MDESBasePage {


@Value("${user.name.byName:}")
private String usernamevalue;

    @MyElement(htmlTag=HTML_TAG.INPUT, findBy=FindBy.NAME, valueToFind="${user.name.byName}")
    private MYWebElement userName;


}
配置文件

@Configuration
   @ComponentScan(basePackages = { "com.bdd.mdes" })
    @PropertySources({
       // we can define according to project
            @PropertySource(value =     "config/${environment}/environment.properties", ignoreResourceNotFound = false)
})

@ImportResource("common-beandefs.xml")
public class TestsAnnotationConfiguration extends
            BDDSpringConfiguration {
   }
sign.in.button是在config.property文件中定义的属性

它应该从属性文件中获取其值,但不是。有人能帮我吗

如果我在
@value
的帮助下打印它的值,如果工作

我只是想知道如何将属性文件中的值传递到用户创建的注释中