HTTP 500 - Cannot create JDBC driver of class '' for connect URL 'null'

前端 未结 3 1973
天命终不由人
天命终不由人 2021-01-07 05:55

I have been searching to fix that problem for 3 days reading forums... Then I decided to ask for some help. Nedless to say that your help would be highly appreciated :-)

3条回答
  •  情歌与酒
    2021-01-07 06:25

    I am using Eclipse STS 3.9.3, tomcat 8.5 and Spring Boot 2.0.0.RELEASE

    I spent my entire morning about this problem. So, I did a lot of things to solve:

    1. Remove jdbc dependence from my pom.

          
      
    2. Declaration resource TOMCAT_HOME/CONF/server.xml whit factory:

      
       ...
         
       ...
      
      

      I realized that I was using Eclipse STS. The tomcat resource on server.xml only works after I put the resource declaration in server.xml inside of "Tomcat v8.5 Server at localhost-config" folder in my Server project. Did not work on TOMCAT_HOME/conf folder in server.xml file.

    3. Change my application.yml to:

      spring:
        datasource:
          platform: postgres
          jndi-name: java:comp/env/jdbc/postgres_jndi
          type: javax.sql.DataSource
          driver-class-name: org.postgresql.Driver
        jpa:
          hibernate:
            ddl-auto: validate
          database-platform: org.hibernate.dialect.PostgreSQL9Dialect
          database: POSTGRESQL
          show-sql: true
          #Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
          properties:
            hibernate:
              temp:
                use_jdbc_metadata_defaults: false
      

    A application.properties will be like:

        spring.datasource.platform= postgres
        spring.datasource.jndi-name= java:comp/env/jdbc/postgres_jndi
        spring.datasource.type= javax.sql.DataSource
        spring.datasource.driver-class-name= org.postgresql.Driver
        spring.jpa.hibernate.ddl-auto= validate
        spring.jpa.hibernatedatabase-platform= org.hibernate.dialect.PostgreSQL9Dialect
        spring.jpa.database= POSTGRESQL
        spring.jpa.show-sql= true
        spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
    
    1. Define a context.xml file in src/main/webapp/META-INF/context.xml with definition:

      
      
          
      
      
    2. Put the file postgresql-42.2.2.jar in the TOMCAT_HOME/lib

提交回复
热议问题