【问题标题】:Spring boot application error with connect PostgreSQL database [duplicate]连接PostgreSQL数据库的Spring Boot应用程序错误[重复]
【发布时间】:2018-09-15 02:45:11
【问题描述】:

我刚刚在https://start.spring.io/ 上生成了新项目,添加了

  1. 网络
  2. 安全性
  3. JPA
  4. PostgreSQL

然后我有描述:

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.

所以我加了

spring.datasource.url= jdbc:postgresql://10.1.2.5/vlex

spring.datasource.username=myUser
spring.datasource.password=myPassword

spring.jpa.hibernate.ddl-auto=none

进入 application.properties,现在我有了:

java.lang.reflect.InvocationTargetException: null
Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.

我无法克服这个问题并卡在这里。有没有办法在 Spring Boot 应用程序中使用 PostgreSQL 9.6?除了application.properties,我没有编辑任何东西

【问题讨论】:

    标签: java spring postgresql spring-boot


    【解决方案1】:

    尝试添加属性:

    spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
    

    或者如果您有特定的hibernate.xml,您可以将相同的属性设置为true

    github上有问题:https://github.com/spring-projects/spring-boot/issues/12007

    类似问题:Postgres Error method org.postgresql.jdbc.PgConnection.createClob() is not implemented

    【讨论】:

      【解决方案2】:

      对于 PostgreSQL 你需要设置这两个属性

      spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
      
      spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
      

      【讨论】:

      • 有效,但下面的这个也有效,不知道我应该接受哪个答案
      • 您确定spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect 是必需的吗?我不应该这么想。
      • 偶:spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false 就够了
      • 啊,好的,我明白了。我以前有时会遇到这个问题。这两条线救了我。现在我知道只有一行就足够了。谢谢大家
      • @Michu93 spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false - 可能比我在回答中提到的属性做得更多,所以如果你只有你所说的例外,我会'已经为这个问题使用了特定的属性
      猜你喜欢
      • 2017-07-13
      • 1970-01-01
      • 2017-09-24
      • 2020-11-03
      • 1970-01-01
      • 2015-05-31
      • 1970-01-01
      • 1970-01-01
      • 2014-06-25
      相关资源
      最近更新 更多