We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
阅读本书,收益颇多,今发现如下不解:
我在新版2.3.2 debug源代码时,发现5.6节113页-115页,使用HSQLDB的运行效果和书中不符,为了验证,将版本降至2.0.2,(两个版本都使用了HikariCP作为连接池)依赖为:
HSQLDB
HikariCP
<dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> <version>2.0.2.RELEASE</version> </dependency>
在DataSourceAutoConfiguration.EmbeddedDatabaseCondition的getMatchOutcome方法中,执行到
DataSourceAutoConfiguration.EmbeddedDatabaseCondition
getMatchOutcome
if (anyMatches(context, metadata, this.pooledCondition)) { return ConditionOutcome .noMatch(message.foundExactly("supported pooled data source")); }
就返回了(两版本相同),而没有继续往下匹配
EmbeddedDatabaseType type = EmbeddedDatabaseConnection .get(context.getClassLoader()).getType(); if (type == null) { return ConditionOutcome .noMatch(message.didNotFind("embedded database").atAll()); } return ConditionOutcome.match(message.found("embedded database").items(type));
因为两个Spring版本debug结果一致,也就进一步看了看,这里意思是内嵌数据源支持连接池,PooledDataSourceAvailableCondition起了作用,有如下发现: DataSourceProperties 实现了 InitializingBean接口,其中:
PooledDataSourceAvailableCondition
DataSourceProperties
InitializingBean
@Override public void afterPropertiesSet() throws Exception { this.embeddedDatabaseConnection = EmbeddedDatabaseConnection .get(this.classLoader); }
被回调时才会去进行获取EmbeddedDatabaseConnection的类型HSQL,
EmbeddedDatabaseConnection
HSQL
PooledDataSourceConfiguration装载时,Import了Hikari,而后Hikari通过DataSourceConfiguration.Hikari进行装载:
PooledDataSourceConfiguration
DataSourceConfiguration.Hikari
@Bean @ConfigurationProperties(prefix = "spring.datasource.hikari") public HikariDataSource dataSource(DataSourceProperties properties) { HikariDataSource dataSource = createDataSource(properties, HikariDataSource.class); if (StringUtils.hasText(properties.getName())) { dataSource.setPoolName(properties.getName()); } return dataSource; }
而EmbeddedDataSourceConfiguration的@Bean dataSource启动时并没有执行到。
EmbeddedDataSourceConfiguration
@Bean dataSource
因整书并没有看完,不知后续是否对此是否有进一步的解释,感觉在这里的表述确和实际不符,也不知我的运行是否有问题?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
阅读本书,收益颇多,今发现如下不解:
我在新版2.3.2 debug源代码时,发现5.6节113页-115页,使用
HSQLDB
的运行效果和书中不符,为了验证,将版本降至2.0.2,(两个版本都使用了HikariCP
作为连接池)依赖为:在
DataSourceAutoConfiguration.EmbeddedDatabaseCondition
的getMatchOutcome
方法中,执行到就返回了(两版本相同),而没有继续往下匹配
因为两个Spring版本debug结果一致,也就进一步看了看,这里意思是内嵌数据源支持连接池,
PooledDataSourceAvailableCondition
起了作用,有如下发现:DataSourceProperties
实现了InitializingBean
接口,其中:被回调时才会去进行获取
EmbeddedDatabaseConnection
的类型HSQL
,PooledDataSourceConfiguration
装载时,Import了Hikari,而后Hikari通过DataSourceConfiguration.Hikari
进行装载:而
EmbeddedDataSourceConfiguration
的@Bean dataSource
启动时并没有执行到。因整书并没有看完,不知后续是否对此是否有进一步的解释,感觉在这里的表述确和实际不符,也不知我的运行是否有问题?
The text was updated successfully, but these errors were encountered: