我无法将一些Hikari属性设置为我的连接。在这一点上,我不是我错过的。
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="poolName" value="springHikariCP" />
<property name="connectionTestQuery" value="SELECT 1" />
<property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" />
<property name="dataSourceProperties">
<props>
<prop key="url">jdbc:mysql://localhost:3306/mysql_demo?zeroDateTimeBehavior=convertToNull</prop>
<prop key="user">root</prop>
<prop key="password">admin</prop>
<prop key="maximumPoolSize">50</prop>
<prop key="maxLifetime">28000</prop>
<prop key="idleTimeout">30000</prop>
<prop key="prepStmtCacheSize">250</prop>
<prop key="prepStmtCacheSqlLimit">2048</prop>
<prop key="cachePrepStmts">true</prop>
<prop key="useServerPrepStmts">true</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<constructor-arg ref="hikariConfig" />
</bean>
当我设置maxLifetime属性时,我收到此错误:
java.beans.IntrospectionException: Method not found: setMaxLifetime
at java.beans.PropertyDescriptor.<init>(Unknown Source)
at com.zaxxer.hikari.util.PropertyBeanSetter.setProperty(PropertyBeanSetter.java:125)
at com.zaxxer.hikari.util.PropertyBeanSetter.setTargetFromProperties(PropertyBeanSetter.java:63)
at com.zaxxer.hikari.pool.PoolUtilities.initializeDataSource(PoolUtilities.java:103)
at com.zaxxer.hikari.pool.BaseHikariPool.<init>(BaseHikariPool.java:153)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:61)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:49)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:78)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
我正在使用:
Hibernate 4.3.7.Final 和Mysql连接器5.1.21 和HikariCP:
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java6</artifactId>
<version>2.3.2</version>
</dependency>
答案 0 :(得分:1)
我需要将财产搬到正确的地方
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="poolName" value="springHikariCP" />
<property name="connectionTestQuery" value="SELECT 1" />
<property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" />
<property name="maximumPoolSize" value="50" />
<property name="maxLifetime" value="28000" />
<property name="idleTimeout" value="30000" />
<property name="dataSourceProperties">
<props>
<prop key="url">jdbc:mysql://localhost:3306/mysql_demo?zeroDateTimeBehavior=convertToNull</prop>
<prop key="user">root</prop>
<prop key="password">admin</prop>
<prop key="prepStmtCacheSize">250</prop>
<prop key="prepStmtCacheSqlLimit">2048</prop>
<prop key="cachePrepStmts">true</prop>
<prop key="useServerPrepStmts">true</prop>
</props>
</property>
</bean>