java - bean 类 [com.zaxxer.hikari.HikariConfig] 的无效属性“url”
问题描述
我是弹簧框架的新手。我在 spring MVC(版本 4)+ hibernate(版本 4)框架应用程序中使用 Hikari 创建一个连接池。运行我的应用程序时出现以下错误。
Invalid property 'url' of bean class [com.zaxxer.hikari.HikariConfig]: Bean property 'url' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
调度程序-servelt.xml:
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<constructor-arg ref="hikariConfig" />
</bean>
<!-- HikariConfig config that is fed to above dataSource -->
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="driverClassName" value="${postgres.driver}" />
<property name="url" value="${postgres.url}?stringtype=unspecified" />
<property name="username" value="${postgres.user}" />
<property name="password" value="${postgres.password}" />
<property name="maximumPoolSize" value="${hikari.maximumPoolSize}" />
<property name="idleTimeout" value="30000" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<array>
<value>XXXX</value>
<value>XXXX</value>
</array>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</prop>
<prop key="hibernate.dialect">${postgres.hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
<prop key="hibernate.order_inserts">true</prop>
<prop key="hibernate.order_updates">true</prop>
<prop key="hibernate.jdbc.batch_versioned_data">true</prop>
</props>
</property>
</bean>
hibernate.properties 文件:
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create/update
hibernate.connection.provider_class=com.zaxxer.hikari.hibernate.HikariConnectionProvider
hibernate.hikari.minimumIdle=5
hibernate.hikari.maximumPoolSize=10
hibernate.hikari.idleTimeout=25200
hibernate.hikari.connectionTimeout=25200
hibernate.hikari.dataSourceClassName=org.postgresql.Driver
hibernate.hikari.dataSource.url=XXXX
hibernate.hikari.dataSource.user=XXXX
hibernate.hikari.dataSource.password=XXXX
hibernate.CharSet=true
hibernate.characterEncoding=true
hibernate.useUnicode=true
pom.xml:
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.4.5</version>
</dependency>
java版本:8,tomcat:8.5
解决方案
推荐阅读
- java - 如何在调试器中查看 java.util.HashMap 子类中的字段?
- python - 如何创建要在模型 pandas python 中使用的汇总表
- java - 使用 Java SDK 列出阿里巴巴 OSS Bucket 中的所有对象
- laravel - 在 laravel 的构造函数中使用会话值
- project-reactor - 如何在本次测试中细化 stepVeriifer 的使用?
- c++ - int 数据如何以位为单位存储在内存中?不是右对齐吗?
- c# - 显示器上缺少 Unity 精灵,但在编辑器中显示
- elasticsearch - 在elasticsearch中使用function_score的术语过滤?
- hibernate - JPA - 尝试创建 NamedEntityGraph 以避免多重选择(具有 OneToOne 和 OneToMany 子级的父级)
- javascript - 使用 ```pm2 stop index.js``` 后 pm2 进程未重新启动