如何在Spring中将属性文件中的值传递给字段的自定义注释
我正在使用Spring4 我创建了一个自定义注释,如如何在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 "
@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
的帮助下打印它的值,如果工作
我只是想知道如何将属性文件中的值传递到用户创建的注释中