Announcement Announcement Module
Collapse
No announcement yet.
Where can I put properties file in the platform, when I deploy Spring webapplication. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Where can I put properties file in the platform, when I deploy Spring webapplication.

    Where can I put properties file in the platform, when I deploy Spring webapplication.
    Such as the application.properties,mail.properties,database.pr operties.

  • #2
    Where can I put properties file in the platform, when I deploy Spring webapplication.

    For standard Java EE WARs, you can place properties files in the root of the classpath as you would in a typical web application. As long as your application code which accesses those properties files resides in the same deployment artifact (i.e., WAR or Web Module), you can also place the properties files in the root of the classpath. Note, however, that OSGi does not support exporting the default package (i.e., the root of the classpath). Thus, if you wish to share properties files across multiple bundles (e.g., in the case of a Shared Services WAR or Web Module), you will then need to place the properties files in a valid Java package (e.g., /com/example/config/mail.properties) and explicitly export that package from the bundle while importing it from other bundles which need the properties files in that package.

    Regards,

    Sam

    Comment


    • #3
      Where can I put properties file in the platform, when I deploy Spring webapplication.

      I just hava a typical web application, you mean put them in the root of the classpath, so you mean that I still hava to put them in the war file? I want to put them outside of the war file, just like in tomcat, I can put them in the /shared/classes
      directory. But in the platform,I didn't find a place to put them which is outside of the war file.I am just a new learner to the platform, please help me?

      Comment


      • #4
        Where can I put properties file in the platform, when I deploy Spring webapplication.

        Hi human2008,

        I've just answered this question in your other thread.

        http://www.springsource.com/beta/applicationplatform/comments.php?DiscussionID=279&page=1#Item_3

        cheers,

        Sam

        Comment


        • #5
          Where can I put properties file in the platform, when I deploy Spring webapplication.

          Thanks, sbrannen.
          Because you know the properties files are used within the xml config file.
          If I want to put the properties in a package, how can the xml visit the properties. we used to use ${mail.enable} to visit the properties.
          If I want to dynamically change the perperties, so I hava to make a bundle for the package? Then put the bundle in the pickup folder? How can I make a package to a bundle?
          Please forgive my simple question.

          Comment


          • #6
            Where can I put properties file in the platform, when I deploy Spring webapplication.

            Hi human2008,

            > How can I make a package to a bundle?

            In OSGi, you export Java packages from your bundles. These packages will typically contain Java classes; however, exported packages can also contain class-path resources such as properties files. This allows you to share a properties file with other bundles. For a working example of this, please refer to version 1.4.0 of the PetClinic sample application (see the "Downloads" link on this page).

            In the PetClinic sample application, the org.springframework.petclinic.infrastructure.hsqld b bundle exports the org.springframework.petclinic.infrastructure package which contains the db.properties file. The org.springframework.petclinic.repository.eclipseli nk bundle then imports that package and loads the db.properties file as a class-path resource as follows:

            <contextroperty-placeholder location="classpath:org/springframework/petclinic/infrastructure/db.properties" />

            > If I want to dynamically change the perperties, so I hava to make a bundle for the package?

            I'm not quite sure what you mean by "dymanically" in this context, but in any case, please note that changes to an underlying properties file used by a property placeholder will not allow you to dynamically change the runtime values of properties injected into Spring-managed components. Standard Spring semantics apply here: if you modify the properties file, you'll need to redeploy your application (or refresh your bundle) to pick up the changes.

            > Then put the bundle in the pickup folder?

            Yes, you could deploy such a bundle via the pickup folder either stand-alone or within a PAR, whichever best suits your needs.

            Regards,

            Sam

            Comment

            Working...
            X