0

I am new to spring framework. I am creating a connection pool using Hikari in spring MVC(version 4) + hibernate (version 4) framework application. I am getting the below error while running my application.

 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?

dispatcher-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 file:

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 version: 8, tomcat: 8.5

SternK
  • 11,649
  • 22
  • 32
  • 46
  • Maybe [this](https://stackoverflow.com/questions/23172643/how-to-set-up-datasource-with-spring-for-hikaricp/24500712) will help. – SternK Jun 16 '20 at 12:34
  • @SternK Thank you for the response. I did the configuration based on the link you shared. – premalatha Jun 16 '20 at 15:08

0 Answers0