0

I am connecting to an external database with a class that extends JdbcTemplate. My problem is that I can't use the globalProperties of the Groovy API because of the Jdbc.

I added these properties I needed in the server-config.properties:

studio.db.driverClassName
studio.db.url
studio.db.username
studio.db.password

I am trying to access them in my application-context.xml with this:

<bean id="jdbc" class="com.dbJdbcTemplate">
    <constructor-arg ref="datasource"/>
</bean>

<bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="url" value="${studio.db.url}"/>
    <property name="driverClassName" value="${studio.db.driverClassName}"/>
    <property name="username" value="${studio.db.username}"/>
    <property name="password" value="${studio.db.password}"/>
</bean>

I receive this error:

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${studio.db.driverClassName}'

How do I access the properties from my bean correctly?

1 Answers1

0

Add a <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer" parent="crafter.properties"/> in your site application-context.xml, like is shown in here https://docs.craftercms.org/en/3.0/site-administrators/engine/engine-site-configuration.html#id3. That lines gives you access to Engine's global properties.

Alfonso Vasquez
  • 598
  • 3
  • 10