Where does the default datasource url for h2 come from on Spring Boot?

后端 未结 1 590
挽巷
挽巷 2020-12-18 16:20

I started a new spring-boot 1.5.3 project. Added some starters:

  • data-jpa
  • starter-web
  • data-rest

And then added

  • de
相关标签:
1条回答
  • 2020-12-18 17:20

    That would be coming from this class, which also contains the defaults for other flavours of in-mem DBs.

    https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java

    H2(EmbeddedDatabaseType.H2, "org.h2.Driver", "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"),

    Which get's loaded via, the DataSourceAutoConfiguration if it meets the criteria,

    https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java

    The default for the database name, testdb, comes from a default set in the Datasourceproperties,

    https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java

    private String name = "testdb";

    0 讨论(0)
提交回复
热议问题