所以我只是使用 spring bootinitializr 使用 maven 和 java 17 设置带有 postgresql 驱动程序、spring web 和 jpa 的项目,然后直接跳到 application.properties 并配置基础知识。但到目前为止,对于所有项目,我都得到了未使用的财产:
# 数据库连接设置
spring.datasource.url=jdbc:postgresql://localhost:5432/your_database_name
spring.datasource.username=你的用户名
spring.datasource.password=你的密码
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=更新
我该如何解决这个问题
我正在尝试连接到数据库 postgresql
如果你想连接到postgreSQL,你必须指定这个属性。不确定哪些属性未使用。
我可以共享连接到 PostgreSQL/TimescaleDB 的属性
spring:
datasource:
url: ${DB_URL:jdbc:postgresql://localhost:5432/postgres}
username: ${DB_USERNAME:postgres}
password: ${DB_PASSWORD:postgres}
driver-class-name: org.postgresql.Driver
jpa:
database: postgresql
database-platform: org.hibernate.dialect.PostgreSQLDialect
show-sql: false
hibernate:
ddl-auto: validate
properties:
hibernate:
format_sql: true
我通过环境变量设置的用户名、密码和 URL。