Announcement Announcement Module
No announcement yet.
Using Properties File with dynamic path Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Properties File with dynamic path

    Hi, I have a normal java project (Not web, Not Android, etc).
    I'm using Spring and Hibernate.
    I need to use 3 different for the 3 different enviroments (develop, test and demo).
    The idea is to have 3 files in 3 different folders. Something like this:


    So, I need to change the path of the on my Application Context to load the right properties files.

    Also I want to change the path from outside project to avoid recompiled every time. Maybe some external XML or TXT file or another properties file.

    It is some way to do that?

    I tried with env-entry, but only works for Web Projects.

    I had tried with one properties file with the path inside to load the second properties file, but I can't make ir work

    Any good Idea?

    Thanks and sorry for my poor english

  • #2
    Use Spring 3.1 and profiles that way you can specify which profile to use, this can be specified by a environment variable. Or simply use an system variable ( and simply use ${configuration-file} to specify the file to load (it will be replaced before the loading).

    However I guess I would go for the profile support...


    • #3
      I can't use system variable because the 3 environment are in the same Server. So the share the windows and the system variable of course.
      I will start readinf about profiles to see what is it.


      Any other ideas are wellcome


      • #4
        A system variable (-D) is per JVM not per system (a bit misleading but that is how it is) ... So not sure why you wouldn't be able to use a system variable as to me it appears it are 3 standalone projects each running in its own jvm (you stated it isn't a web application so you don't have a shared system).


        • #5
          Yes, you are right, my fault!, hehe.

          Anyway, I can't use system variable because, some times (most of them), the proyect is use like a Core proyect and then is put inside a Web proyect who have only one Apache Tomcat for the 3 enviroments.
          But some times, is used alone, so I can't use web.xml, because some times it not exists.

          I know, is strange, he

          Thanks anyway

          I was checking Spring Profiles, I start thinking that it can't help me, because I need to change the profile using some XML o TXT file outside the proyect