Wednesday, 29 February 2012

Spring bean variables with data loader command line

If you use Apex Data Loader from the command line, you will know that changing usernames, passwords, and environments is a bit painful if you have more than one bean in your process-conf.xml file. Adding variables should be easy but getting the syntax right without an IDE is not. I couldn't find much help on the web so a Java guru colleague came through with the following fix.

In the head of the process-conf.xml file, below the <beans> tag and above the first <bean>, add the following code to declare a "user" variable with a specified Salesforce username:

<bean id="user" class="java.lang.String">
<constructor-arg value="yourusername"/>

Then in the map entries replace

<entry key="sfdc.username" value="yourusername"/>

with the following code:

<key> <value>sfdc.username</value></key>
<ref bean="user" />

Do the same in each of the process beans, and use the same technique to declare variables for your environment, encrypted password, and output folders.

To share a properties file external to your process-conf.xml file, use the Spring PropertyPlaceholderConfigurer as detailed in this

Thanks to Jeremy for the tips and syntax.

No comments:

Post a Comment