… #23538

Bug fix for Can't connect to a local h2 database created without username #23538

The changes were,

1 The jdbc username/password is now determined by evaluating the existence of the jdbc url

2 The postProcessBeanDefinitionRegistry method in the TestDatabaseAutoConfiguration does not replace the datasource by the embedded database reference anymore.

This enables allowing a "" empty string username and password as documented in the bug description for the jdbc databases and also enables the database declarated type to define the intrinsic db type selected. So, a configuration of the below are both supported.

1 database=h2

spring.datasource.schema=classpath:db/${database}/schema.sql spring.datasource.data=classpath:db/${database}/data.sql

2

spring.datasource.url=jdbc:h2:~/test spring.datasource.schema=classpath:db/${database}/schema.sql spring.datasource.data=classpath:db/${database}/data.sql spring.datasource.username= spring.datasource.password= spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

Tests: I've made sure all unit tests and integration tests are working as expected. I've used spring-petclinic (2.3.0.BUILD-SNAPSHOT)(springboot-2.4.0-SNAPSHOT) for the integration testing to validate changes.

Comment From: wilkinsona

Thanks for the pull request. Unfortunately, it causes several tests to fail. The failures are:

:spring-boot-project:spring-boot-autoconfigure:test
    org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties()
    org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties()
    org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties()
    org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties()
    org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername()
    org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername()
    org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername()
    org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername()
    org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword()
    org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword()
    org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword()
    org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword()
    org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername()
    org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername()
    org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername()
    org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername()
    org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()
    org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()
    org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()
    org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()

:spring-boot-project:spring-boot-test-autoconfigure:test
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository()
    org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository()
    org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository()
    org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository()
    org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase()
    org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase()
    org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase()
    org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase()
    org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource()
    org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource()
    org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource()
    org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource()
    org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault()
    org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()
    org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()
    org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()
    org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()

The jdbc username/password is now determined by evaluating the existence of the jdbc url

This doesn't feel quite right to me. Instead, I think we'll need to update EmbeddedDatabaseConnection so that it returns false for an H2 database that doesn't have mem in its protocol. This would result in isEmbedded(String driverClass) being deprecated and a new method being introduced that takes the driverClass and the URL.

As @snicoll said this isn't going to be easy to fix and I'm not certain that what I've described above is the right fix without trying it. If you'd like to update this pull request to address the test failures and try this approach, then you are more than welcome to do so. Equally, if you'd prefer that we figure out what needs to be done then we can take care of it in due course.

Comment From: somayaj

Hi Andiy, Ok, I can make the change here to fix the tests. But again, if you don/t agree with the apporach (checking for existing url) then there's no point.

I can also make the change to check for the "mem" in the url if you want and give it a try if that's ok.

Let me know what you might think.

Thanks, Asha

On Thu, Oct 15, 2020 at 1:30 AM Andy Wilkinson notifications@github.com wrote:

Thanks for the pull request. Unfortunately, it causes several tests to fail. The failures are:

:spring-boot-project:spring-boot-autoconfigure:test org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties() org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties() org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties() org.springframework.boot.autoconfigure.flyway.FlywayAutoConfigurationTests > createDataSourceFallbackToEmbeddedProperties() org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername() org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername() org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername() org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfigurationTests > testEmbeddedTypeDefaultsUsername() org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword() org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword() org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword() org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determinePassword() org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername() org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername() org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername() org.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesTests > determineUsername() org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties() org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties() org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties() org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfigurationTests > overrideDataSourceAndFallbackToEmbeddedProperties()

:spring-boot-project:spring-boot-test-autoconfigure:test org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > didNotInjectExampleComponent() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > flywayAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository() org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTestIntegrationTests > testRepository() org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabaseWithMultipleDatasourcesIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > didNotInjectExampleRepository() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > flywayAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > liquibaseAutoConfigurationWasImported() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestIntegrationTests > testJdbcTemplate() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests > replacesDefinedDataSourceWithExplicit() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository() org.springframework.boot.test.autoconfigure.jdbc.JdbcTestWithIncludeFilterIntegrationTests > testRepository() org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase() org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase() org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase() org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfigurationTests > replaceWithUniqueDatabase() org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource() org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource() org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource() org.springframework.boot.test.autoconfigure.jooq.JooqTestWithAutoConfigureTestDatabaseIntegrationTests > replacesAutoConfiguredDataSource() org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestIntegrationTests > replacesDefinedDataSourceWithEmbeddedDefault() org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace() org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace() org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace() org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfigurationNoEmbeddedTests > applyAnyReplace()

The jdbc username/password is now determined by evaluating the existence of the jdbc url

This doesn't feel quite right to me. Instead, I think we'll need to update EmbeddedDatabaseConnection so that it returns false for an H2 database that doesn't have mem in its protocol. This would result in isEmbedded(String driverClass) being deprecated and a new method being introduced that takes the driverClass and the URL.

As @snicoll said https://github.com/spring-projects/spring-boot/issues/23538#issuecomment-708242363 this isn't going to be easy to fix and I"m not certain that what I've described above is the right fix without trying it. If you'd like to update this pull request to address the test failures and try this approach, then you are more than welcome to do so. Equally, if you'd prefer that we figure out what needs to be done then we can take care of it in due course.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-boot/pull/23693#issuecomment-708930209, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIRAZGOORFQA5WLOGWMZ7C3SK2JJXANCNFSM4SRIFC7A .

Comment From: wilkinsona

I can also make the change to check for the "mem" in the url if you want and give it a try if that's ok.

Yes, that's certainly ok. It's what I would try if I was attempting to fix the problem.

Comment From: somayaj

Sure, yes. My local works (when it works that is, the mac is crashing every time I try to build here...)

Comment From: somayaj

Fyi, not able to find the root cause here for these, [ant:checkstyle] /root/.gradle/caches/modules-2/files-2.1/com.samskivert/jmustache/1.15/7b3b15951d13b774c76db2f4e14d977952f8b4d8/jmustache-1.15.jar(com/samskivert/mustache/Mustache.java):306: warning: no @return [ant:checkstyle] Reader getTemplate (String name) throws Exception;

Comment From: snicoll

@somayaj thanks for your efforts on this issue. There was a number of things that still need to be covered (or reverted as they were changing behaviour beyond the scope of this issue). See c0b267f for more details.

Comment From: snicoll

FTR this bug fix was meant to be fixed in 2.3.x. I'll backport the fix see #23721.

Comment From: snicoll

This issue is noteworthy due to the following behaviour changes:

  • Now that the embedded mode is detected based on the actual JDBC URI and not only the driver at play, H2, HSQL and Derby with file-based persistence (server mode) won't be initialised by default. spring.datasource.initialization-mode=always needs to be set if that's what you want.
  • Similarly, the default user name doesn't default to sa anymore for those. If you've created a database before upgrading to this version, it is likely it was created with sa as the default username and upgrading will lead to an authentication failure. Setting spring.datasource.username=sa will restore the previous behaviour.

Comment From: izeye

This has been labeled as status: noteworthy, but a note for this seems to be missing in Spring Boot 2.4.0 RC1 Release Notes.

Comment From: snicoll

Thank you very much for the nudge @izeye. I've added a section in the release notes for RC1.