Announcement Announcement Module
Collapse
No announcement yet.
Override the launchContext.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Override the launchContext.xml

    Hi all,
    ClassPathXmlApplicationContext is always the expecting the launch-context.xml or job.xml file to be part of the bundle package (i.e. jar) now I want to be read the file from Obsolute path.
    Can any one please let me know how to achieve this.

    ClassPathXmlApplicationContext configAppContext = new ClassPathXmlApplicationContext("launch-context.xml");

    OR atleast if at all i can achieve this?
    I need to override the property value set in the context.xml file

    <contextroperty-placeholder location="classpath:batch-mysql.properties" />

    the location value has to be read from the obsolete path.

    <contextroperty-placeholder location="/home/ravi/batch-mysql.properties" />


    OR to override the property value of the batch-mysql.properties
    batch-mysql.properties contents are:
    batch.jdbc.driver=com.mysql.jdbc.Driver
    batch.jdbc.url=jdbc:mysql://localhost:3306/test
    batch.jdbc.user=root
    batch.jdbc.password=kodiak
    batch.jdbc.testWhileIdle=true
    batch.jdbc.validationQuery=SELECT 1
    batch.jdbc.verifyCursorPosition=true
    batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-mysql.sql
    batch.schema.script=classpath:/org/springframework/batch/core/schema-mysql.sql
    batch.business.schema.script=classpath:business-schema-mysql.sql
    batch.data.source.init=true
    batch.database.incrementer.class=org.springframewo rk.jdbc.support.incrementer.MySQLMaxValueIncrement er
    batch.database.incrementer.parent=columnIncremente rParent
    batch.lob.handler.class=org.springframework.jdbc.s upport.lob.DefaultLobHandler
    batch.jdbc.pool.size=6
    batch.grid.size=50
    batch.verify.cursor.position=true


    I need to override this batch.jdbc.url value based on the deployment server network address

  • #2
    I wrote an API that facilitates property overrides from the environment. It works with Spring projects and we use it at my office.

    Allowing environment overrides to be read in without having to crack open the deployment artifact.

    So it can be done.

    I would avoid reading launch-context.xml from an external location. It makes it too tempting to modify beans at runtime and could result in unpredictable behavior.

    Jeff

    Comment

    Working...
    X