java - override spring batch admin to use mysql database -


i trying use mysql database instead of default hsql in spring batch admin. per documentation

http://docs.spring.io/spring-batch-admin/reference/reference.xhtml , using jndi datasource spring batch admin

i copied env-context.xml src/main/resources/meta-inf/batch/override/manager/env-context.xml , changed configuration value from

<value>classpath:batch-${environment:hsql}.properties</value> 

to

 <value>classpath:batch-mysql.properties</value> 

below full configuration.

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">      <!--  use set additional properties on beans @ run time -->     <bean id="placeholderproperties" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">         <property name="locations">             <list>                 <value>classpath:/org/springframework/batch/admin/bootstrap/batch.properties</value>                 <value>classpath:batch-default.properties</value>                 <value>classpath:batch-mysql.properties</value>             </list>         </property>         <property name="systempropertiesmodename" value="system_properties_mode_override" />         <property name="ignoreresourcenotfound" value="true" />         <property name="ignoreunresolvableplaceholders" value="false" />         <property name="order" value="1" />     </bean>  </beans> 

i tried coping data-source-context.xml same folder , changing configurations mysql

<?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:jdbc="http://www.springframework.org/schema/jdbc"     xsi:schemalocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">      <bean id="datasource"         class="org.apache.commons.dbcp.basicdatasource">         <property name="driverclassname" value="com.mysql.jdbc.driver" />         <property name="url" value="jdbc:mysql://localhost/batch" />         <property name="username" value="root" />         <property name="password" value="root" />         <property name="testwhileidle" value="true"/>         <property name="validationquery" value="select 1"/>     </bean>      <bean id="transactionmanager"         class="org.springframework.jdbc.datasource.datasourcetransactionmanager">         <property name="datasource" ref="datasource" />     </bean>      <!--  initialise database if enabled: -->     <jdbc:initialize-database data-source="datasource" enabled="false" ignore-failures="drops">         <jdbc:script location="classpath*:/org/springframework/batch/core/schema-drop-mysql.sql"/>         <jdbc:script location="classpath:/org/springframework/batch/core/schema-mysql.sql"/>         <jdbc:script location="classpath:/business-schema-mysql.sql"/>     </jdbc:initialize-database>  </beans> 

but still using hsql database? how override default configuration use mysql database ?

you shouldn't replace <value>classpath:batch-${environment:hsql}.properties</value>. instead, pass in environment variable environment set mysql. should cause appropriate components pick correct database. can read more feature here: http://docs.spring.io/spring-batch-admin/reference/infrastructure.html#environment_settings


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -