When I was using spring2.5, my setup was as follows: To read configurations:
@Configuration
@PropertySource({ "file:/etc/appconf/project/sharding/app-rule.properties"})
public class AppConfigProperties {
}
Configurations from file:
spring.shardingsphere.datasource.local00.type=com.local.MySQLDataSource
spring.shardingsphere.datasource.local00.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.local00.jdbcUrl=jdbc:mysql://localhost:3306/local00
spring.shardingsphere.datasource.local00.username=app_devuser
spring.shardingsphere.datasource.local00.password=######
spring.shardingsphere.datasource.local00.poolName=local00
shardingDataSource Bean:
@Data
@Component("shardingDataSource")
@Configuration
public class MySQLDataSource extends HikariDataSource {
private Map<String, String> config;
public void addConfig(String key, String value) {
if (config==null){
config = new HashMap<>();
}
config.put(key, value);
}
}
Now, when earlier I called this function:
DataSource value = context.getBean("shardingDataSource", DataSource.class);
I got this output as value of value, among other things:
{dataSourceMap: {"local00": MySqlDataSource}}
But now after upgrading to spring 3.1.2, dataSourceMap is not being populated. As a result healthcheck is failing for the application since it couldn't find dataSource configuration
I expect the db queries to work as before. Thanks
Finally resolved this error:
Created a folder META-INF/spring
File Name: src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
With Value: org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration
This resolved the error