aspose file tools*
The moose likes Spring and the fly likes Spring and command line arguments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring and command line arguments" Watch "Spring and command line arguments" New topic
Author

Spring and command line arguments

Alex Armenteros
Ranch Hand

Joined: May 05, 2010
Posts: 73
I'd like to start an application like this


java -jar application.jar "path/conffile.conf"

and use this

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>

I'd like to set the location of the propertyConfigurer to the file passed as an argument
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Instead of command line arguments, why not put the value inside the properties file?

i would also ask, why you need this functionality? I am guessing there is a different solution that would solve the reason why you need this, rather than trying something obscure. Usually, if you can't get the results quickly that you want, I tend to question why that design. There is always a simple way to accomplish stuff in Spring.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Alex Armenteros
Ranch Hand

Joined: May 05, 2010
Posts: 73
I need to keep different configuration files to have the same process running in the same machine with different properties
Alex Armenteros
Ranch Hand

Joined: May 05, 2010
Posts: 73
Finally I got it right... Sorry for explaining myself so bad.

I got the desired result with this.

XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("Beans.xml"));
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(new FileSystemResource(args[0]));
cfg.postProcessBeanFactory(factory);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring and command line arguments