Include non-default DataSource candidates
This commit updates H2ConsoleAutoConfiguration to consider non-default data sources when logging connection URLs. See gh-44293 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
parent
0eeb0b61de
commit
8d27f4ee7c
|
@ -47,6 +47,7 @@ import org.springframework.core.log.LogMessage;
|
|||
* @author Marten Deinum
|
||||
* @author Stephane Nicoll
|
||||
* @author Phillip Webb
|
||||
* @author Yanming Zhou
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@AutoConfiguration(after = DataSourceAutoConfiguration.class)
|
||||
|
@ -113,7 +114,10 @@ public class H2ConsoleAutoConfiguration {
|
|||
}
|
||||
|
||||
private List<String> getConnectionUrls(ObjectProvider<DataSource> dataSources) {
|
||||
return dataSources.orderedStream().map(this::getConnectionUrl).filter(Objects::nonNull).toList();
|
||||
return dataSources.orderedStream(ObjectProvider.UNFILTERED)
|
||||
.map(this::getConnectionUrl)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private String getConnectionUrl(DataSource dataSource) {
|
||||
|
|
|
@ -57,6 +57,7 @@ import static org.mockito.Mockito.mock;
|
|||
* @author Stephane Nicoll
|
||||
* @author Shraddha Yeole
|
||||
* @author Phillip Webb
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
class H2ConsoleAutoConfigurationTests {
|
||||
|
||||
|
@ -206,7 +207,7 @@ class H2ConsoleAutoConfigurationTests {
|
|||
return mockDataSource("anotherJdbcUrl");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Bean(defaultCandidate = false)
|
||||
@Order(0)
|
||||
DataSource someDataSource() throws SQLException {
|
||||
return mockDataSource("someJdbcUrl");
|
||||
|
|
Loading…
Reference in New Issue