File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring and command line arguments

 
Alex Armenteros
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Alex Armenteros
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to keep different configuration files to have the same process running in the same machine with different properties
 
Alex Armenteros
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic