HikariPool-1-driverClassName需要jdbcUrl [英] HikariPool-1 - jdbcUrl is required with driverClassName

查看:465
本文介绍了HikariPool-1-driverClassName需要jdbcUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我回去对旧程序进行编程 https://github.com/JonkiPro/REST-网络服务.我已经将Spring Boot从版本15.6更新到版本2.0.0.我在编译时遇到了许多问题,但我无法处理.好吧,在编译过程中,他把我扔到了控制台上

I went back to programming my old program https://github.com/JonkiPro/REST-Web-Services. I've updated Spring Boot from version 15.6 to version 2.0.0. I have encountered many problems with compilation, but I can not deal with one. Well, during compilation, he throws me in the console

2018-03-18 21:54:53.339 ERROR 3220 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : HikariPool-1 - jdbcUrl is required with driverClassName.
2018-03-18 21:54:55.392  INFO 3220 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'unit'
2018-03-18 21:54:56.698  INFO 3220 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'unit'
2018-03-18 21:54:56.778 ERROR 3220 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig           : HikariPool-1 - jdbcUrl is required with driverClassName.
2018-03-18 21:54:56.782 ERROR 3220 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService' defined in file [C:\Users\Jonatan\Documents\GitHub\REST-Web-Services\web\out\production\classes\com\web\web\security\service\impl\UserDetailsServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#65d6e77b' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#65d6e77b': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
2018-03-18 21:54:56.821  WARN 3220 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

我从来没有犯过这样的错误.我完全不知道这意味着什么.我在基地的财产看起来像这样

I've never had such a mistake. I do not know what it means completely. My properties for the base look like this

spring:
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql:database
    username: root
    password: root
    schema: classpath:/db/init/schema.sql

我不知道该如何处理该错误.我已经进行了很长时间的编程,但是第一次满足了hikari的概念.我正在使用Tomcat(在Spring Boot中)服务器和PostgreSQL数据库.

I do not know how to deal with this error. I've been programming quite a long time, but for the first time I'm meeting the concept of hikari. I'm using a Tomcat(in Spring Boot) server and a PostgreSQL database.

推荐答案

在其他情况下,我遇到了同样的问题. 来自 79.数据访问-配置自定义数据源

I had the same issue in another context. From the 79. Data Access - Configure a Custom DataSource

如果您碰巧在类路径上有Hikari,则此基本设置无效,因为Hikari没有url属性(但确实具有jdbcUrl属性)

if you happen to have Hikari on the classpath, this basic setup does not work, because Hikari has no url property (but does have a jdbcUrl property)

Hikari是Spring Boot 2中的默认池.

Hikari is the default pool in spring boot 2.

因此您可以替换配置 url: jdbc:postgresql:database-> jdbc-url: jdbc:postgresql:database

so you can replace the config url: jdbc:postgresql:database -> jdbc-url: jdbc:postgresql:database

或者您可以保留配置,但是需要定义另一个Bean来处理映射(别名)

or you can keep the config but you need to define another Bean to handle the mapping (aliases)

@Bean
@Primary
@ConfigurationProperties("app.datasource")
public DataSourceProperties dataSourceProperties() {
    return new DataSourceProperties();
}

@Bean
@ConfigurationProperties("app.datasource")
public DataSource dataSource(DataSourceProperties properties) {
    return properties.initializeDataSourceBuilder().
        .build();
}

这篇关于HikariPool-1-driverClassName需要jdbcUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆