MyDataSourceConfiguration
@Configuration
public class MyDataSourceConfiguration {
@Bean("accountDataSource")
public DataSource accountDataSource() {
return new XxxxDataSource();
}
}
spring-configuration-metadata.json
{
"hints": [
{
"name": "my.exclude-data-source-classname-or-beanname",
"providers": [
{
"name": "class-reference",
"parameters": {
"target": "javax.sql.DataSource"
}
},
{
"name": "spring-bean-reference",
"parameters": {
"target": "javax.sql.DataSource"
}
}
]
}
]
}
application.yml
my:
exclude-data-source-classname-or-beanname:
- com.alibaba.druid.pool.DruidDataSource # the className
- accountDataSource # the beanName
Comment From: snicoll
@wangliang181230 thanks for the report but this is working as documented. The documentation states:
Only one provider can be active for a given property, but you can specify several providers if they can all manage the property in some way. Make sure to place the most powerful provider first, as the IDE must use the first one in the JSON section that it can handle. If no provider for a given property is supported, no special content assistance is provided, either.
Ignoring the fact that this use case is not meant to be supported, I would not recommend having a property that is both a bean reference and a bean type. While what you type in configuration is ultimately a String, it is better for the value to have a well defined semantic.