我正在尝试使用动态配置Spring的注释。我尝试过的解决方案(this和this)在我的情况下会产生以下错误:
Caused by: SpelEvaluationException: EL1007E: Property or field
'DbCreatorIndexNameConfig' cannot be found on null所涉及的注释是:
@ComponentScan(basePackageClasses = DbCreatorIndexNameConfig.class)
@Document(indexName = "#{DbCreatorIndexNameConfig.indexName()}", type = "video",
shards = 1, replicas = 0)
public class Video implements EsModel {
//...问题中的豆子:
@Configuration("DbCreatorIndexNameConfig")
@ComponentScan(basePackageClasses = Video.class)
public class DbCreatorIndexNameConfig {
@Value("video_default")
public String indexName;
@Bean
public String indexName() {
return indexName;
}
public void setIndexName(String indexName) {
this.indexName = indexName;
}
}备注:
new AnnotationConfigApplicationContext(EsSpringTemplate.class, DbCreatorIndexNameConfig.class);连接到应用程序上下文中。annotationConfigApplicationContext.getBeanDefinitionNames()中。任何想法都是非常感谢的!谢谢!
发布于 2017-08-29 09:20:15
按以下方式修改它:-必须使用“@”来访问spel中的bean
@Document(indexName = "#{@DbCreatorIndexNameConfig.indexName()}", type = "video",
shards = 1, replicas = 0)https://stackoverflow.com/questions/45934683
复制相似问题