I have a project with spring and maven. I found that using profiles, maven could change the properties of the data source. But what if in production the datasource is with a lookup like this, how to do the profiles for this: one with a basic datasource and the other a jee lookup.
<jee:jndi-lookup id="dataSourcejndi" jndi-name="jdbc/BGGDS"
default-value="null" resource-ref="true"/>
This is how the profiles are in the pom.xml
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
<jdbc.driver>org.hsqldb.jdbcDriver</jdbc.driver>
<jdbc.url>jdbc:hsqldb:hsql://localhost/test</jdbc.url>
<jdbc.username>sa</jdbc.username>
<app.datasource>dataSource</app.datasource>
<jdbc.password />
<jdbc.isolation />
</properties>
</profile>
<profile>
<id>hudson</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
<jdbc.driver>org.hsqldb.jdbcDriver</jdbc.driver>
<jdbc.url>jdbc:hsqldb:hsql://localhost/othertest</jdbc.url>
<app.datasource>dataSource</app.datasource>
<jdbc.username>sa</jdbc.username>
<jdbc.password />
</properties>
</profile>
</profiles>
and this the configutarion of spring
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<!--Datasource pruebas" -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
p:driverClassName="${jdbc.driver}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}" />
<!-- La definición del Factory de Session con Anotaciones -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="${app.datasource}" />
<property name="hibernateProperties">
<props>
<!--Pruebas
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>-->
<!--Produccion-->
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>Test.hbm.xml</value>
</list>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- Injected properties
-->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
And this work for normal datasources, but what if I need a lockup.