gpt4 book ai didi

hibernate - 为什么 hikaricp 给我找不到方法 : setUrl at startup?

转载 作者:行者123 更新时间:2023-12-01 12:38:50 27 4
gpt4 key购买 nike

我正在开发一个没有 Maven 或 Spring 的 GWT 应用程序,但我想使用 HikariCP 作为我的连接池,所以我从 Maven 的中央存储库下载了 HikariCP-2.2.4.jar 以及 pgjdbc-ng-0.3-complete.jar我的 postgresql 驱动程序;最后,我将我的 hibernate 库从 4.1 更新到 4.3。

我在我的 hibernate.cfg.xml 上使用了以下 HikariCP 属性

<property name="hibernate.connection.provider_class">com.zaxxer.hikari.hibernate.HikariConnectionProvider</property>
<property name="hibernate.hikari.dataSourceClassName">com.impossibl.postgres.jdbc.PGDataSource</property>
<property name="hibernate.hikari.dataSource.user">user</property>
<property name="hibernate.hikari.dataSource.password">pass</property>
<property name="hibernate.hikari.maximumPoolSize">10</property>
<property name="hibernate.hikari.dataSource.url">jdbc:postgresql://localhost:5432/db</property>

现在,当我启动应用程序时,它会给我下一个异常:

org.hibernate.HibernateException: java.lang.RuntimeException: java.beans.IntrospectionException: Method not found: setUrl at com.zaxxer.hikari.hibernate.HikariConnectionProvider.configure(HikariConnectionProvider.java:84) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845) at org.persistencias.HibernateSessionFactory.(HibernateSessionFactory.java:43) at org.persistencias.BaseHibernateDAO.getSession(BaseHibernateDAO.java:14)

. . . Caused by: java.lang.RuntimeException: java.beans.IntrospectionException: Method not found: setUrl at com.zaxxer.hikari.util.PropertyBeanSetter.setProperty(PropertyBeanSetter.java:129) at com.zaxxer.hikari.util.PropertyBeanSetter.setTargetFromProperties(PropertyBeanSetter.java:58) at com.zaxxer.hikari.util.PoolUtilities.initializeDataSource(PoolUtilities.java:134) at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:142) at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:109) at com.zaxxer.hikari.HikariDataSource.(HikariDataSource.java:78) at com.zaxxer.hikari.hibernate.HikariConnectionProvider.configure(HikariConnectionProvider.java:80) ... 49 more Caused by: java.beans.IntrospectionException: Method not found: setUrl at java.beans.PropertyDescriptor.(PropertyDescriptor.java:110) at com.zaxxer.hikari.util.PropertyBeanSetter.setProperty(PropertyBeanSetter.java:120) ... 55 more

我已经在 stackoverflow 上进行了搜索并进行了谷歌搜索,但到目前为止还没有找到任何东西,有人可以给我一些提示吗?

谢谢!

最佳答案

pgjdbc-ng PGDataSource 没有 url 属性的 setter 。 URL 由 pgjdbc-ng 在内部“组合”。您需要使用各个属性设置数据源:


hibernate.hikari.dataSource.host=localhost
hibernate.hikari.dataSource.port=5432
hibernate.hikari.dataSource.database=db

关于hibernate - 为什么 hikaricp 给我找不到方法 : setUrl at startup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26912409/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com