带有 Spring 引导的蟑螂数据库
Cockroach Db with Spring Boot
在 Spring 引导和 Spring 批处理中使用 Coacroach Db 时,出现以下错误。
org.postgresql.util.PSQLException: ERROR: invalid value for parameter "TimeZone": "Europe/London"
详细信息:系统找不到指定的路径。
Application.properties
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect
spring.datasource.username=root
spring.datasource.password=
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable&serverTimezone=UTC&useLegacyDatetimeCode=false
spring.jpa.properties.hibernate.jdbc.time_zone= UTC
spring.batch.initialize-schema = always
我还按照某处提到的那样添加了这个和上面的属性,但没有帮助。
@PostConstruct
void started() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
所以看到了一些问题。
1. You said you are using Coacroach Db but you seem to be loading a JDBC JAR and ULR string for Postgres.
2. Posgres does not have "Europe/London" as a valid TimeZone String. There is a "Europe/London GB GB-Eire"
See: https://www.postgresql.org/docs/8.1/datetime-keywords.html
3. You have a space in the time zone property name.
This: spring.jpa.properties.hibernate.jdbc.time_zone= UTC
Should Be: spring.jpa.properties.hibernate.jdbc.time_zone=UTC
出于好奇,您使用的是哪个操作系统?我们有一个 open issue relating to timezones,它会影响 Windows。
当您指定 UTC 时区时,是否收到与 "Europe/London" 相同的错误?如果您尝试使用数字偏移量(例如“+0:00”)会怎么样?
此外,通过URL设置时区时,参数应为timezone=utc
(或您想要的任何其他值)。
在 Spring 引导和 Spring 批处理中使用 Coacroach Db 时,出现以下错误。
org.postgresql.util.PSQLException: ERROR: invalid value for parameter "TimeZone": "Europe/London"
详细信息:系统找不到指定的路径。
Application.properties
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect
spring.datasource.username=root
spring.datasource.password=
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable&serverTimezone=UTC&useLegacyDatetimeCode=false
spring.jpa.properties.hibernate.jdbc.time_zone= UTC
spring.batch.initialize-schema = always
我还按照某处提到的那样添加了这个和上面的属性,但没有帮助。
@PostConstruct
void started() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
所以看到了一些问题。
1. You said you are using Coacroach Db but you seem to be loading a JDBC JAR and ULR string for Postgres.
2. Posgres does not have "Europe/London" as a valid TimeZone String. There is a "Europe/London GB GB-Eire"
See: https://www.postgresql.org/docs/8.1/datetime-keywords.html
3. You have a space in the time zone property name.
This: spring.jpa.properties.hibernate.jdbc.time_zone= UTC
Should Be: spring.jpa.properties.hibernate.jdbc.time_zone=UTC
出于好奇,您使用的是哪个操作系统?我们有一个 open issue relating to timezones,它会影响 Windows。
当您指定 UTC 时区时,是否收到与 "Europe/London" 相同的错误?如果您尝试使用数字偏移量(例如“+0:00”)会怎么样?
此外,通过URL设置时区时,参数应为timezone=utc
(或您想要的任何其他值)。