This is how I do it. My app-config file
<bean id="mySqlSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" p:dataSource-ref="mySqlDataSource"> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> ..... </props> </property> <property name="configLocation" value="WEB-INF/hibernate.cfg.xml"/> </bean>
Then I have these variables defined in different property files, namely etc / dev / pejl.properties , etc / test / pejl.properties , etc. / prod / payl.properties .
Then, using my ant script, I create for development ...
<target name="deploydevwar" depends="build" description="Deploy application as a WAR file"> <copy overwrite="true" todir="${web.dir}/WEB-INF/classes"> <fileset dir="${etc.dir}/dev"> <include name="*.properties" /> </fileset> </copy> <war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml"> ... </war> <copy todir="${deploy.path}" preservelastmodified="true"> .. </copy> <copy overwrite="true" todir="${appserver.home}"> ... </copy> </target>
for the test.
<target name="deploytestwar" depends="build" description="Deploy application as a WAR file"> <copy overwrite="true" todir="${web.dir}/WEB-INF/classes"> <fileset dir="${etc.dir}/test"> <include name="*.properties" /> </fileset>
etc.
source share