为什么 h2 更改用户名和密码不起作用? Spring 启动应用程序
Why does h2 changing of username and password dont work? Spring boot app
我有 gradle spring 在 eclipse.When 中使用 h2 数据库启动应用程序在应用程序中添加配置 properties.Why?
我的 application.properties
文件:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.data-username=test
spring.datasource.data-password=test
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
控制台:
2020-06-27 22:49:21.425 INFO 13960 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration
: H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:testdb'
build.gradle
中的依赖项:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'com.h2database:h2'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-jaxb:2.9.0'
implementation 'com.squareup.okhttp3:okhttp:4.7.2'
implementation("com.squareup.okhttp3:logging-interceptor:4.7.2")
implementation('javax.xml.bind:jaxb-api:2.3.0')
implementation('javax.activation:activation:1.1')
implementation('org.glassfish.jaxb:jaxb-runtime:2.3.0')
}
它仍然有效,因为您设置的用户名和密码错误。
根据documentation、属性spring.datasource.data-username
集
Username of the database to execute DML scripts (if different).
和spring.datasource.data-password
集
Password of the database to execute DML scripts (if different).
您需要设置spring.datasource.username
和spring.datasource.password
。
您的配置文件应如下所示:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=test
spring.datasource.password=test
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
我有 gradle spring 在 eclipse.When 中使用 h2 数据库启动应用程序在应用程序中添加配置 properties.Why?
我的 application.properties
文件:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.data-username=test
spring.datasource.data-password=test
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
控制台:
2020-06-27 22:49:21.425 INFO 13960 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration
: H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:testdb'
build.gradle
中的依赖项:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'com.h2database:h2'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-jaxb:2.9.0'
implementation 'com.squareup.okhttp3:okhttp:4.7.2'
implementation("com.squareup.okhttp3:logging-interceptor:4.7.2")
implementation('javax.xml.bind:jaxb-api:2.3.0')
implementation('javax.activation:activation:1.1')
implementation('org.glassfish.jaxb:jaxb-runtime:2.3.0')
}
它仍然有效,因为您设置的用户名和密码错误。
根据documentation、属性spring.datasource.data-username
集
Username of the database to execute DML scripts (if different).
和spring.datasource.data-password
集
Password of the database to execute DML scripts (if different).
您需要设置spring.datasource.username
和spring.datasource.password
。
您的配置文件应如下所示:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=test
spring.datasource.password=test
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true