I have a Spring project that uses Maven and has several profiles that allow it to run on different settings with resource filtering. Some of the settings have JNDI, and some do not. For those that do not require a JDBC data source.
What is the best way to handle this setup? I want to avoid doing anything with multiple files and ant -run or something like that. What leaves me with:
- Setting up two beans and filtering my resources to enable one or the other.
- Something I didn't think about?
Here is an example of the first bullet:
<bean id="jdbcDataSource" 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}"/> <bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean" p:jndiName="${jndi.name}" /> <bean id="someBean" class="com.whatever.SomeBeanImpl" p:dataSource-ref="${dataSource}"/>
I am interested to hear about other ways that people have achieved this and why they went with this decision. Or if they went with this decision and why.
source share