Announcement Announcement Module
Collapse
No announcement yet.
how to configure spring roo to read database.configuration outside application. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to configure spring roo to read database.configuration outside application.

    Hi,

    Im created one module (java jar file) that handle all data model and database connection using spring roo. It works great, i can use it with desktop app and web app. My problem is by default the database.configuration is stored in the META-INF/spring folder and it read the database configuration inside the jar file. How i can configure the my module to read the database.configuration outside the jar file or read from other application.

  • #2
    The traditional way to meet this requirement is to register your DataSource via JNDI; your application can then (in the Spring bean file) look up the datasource (and/or an associated EntityManagerFactory if using JPA) using its JNDI name, without having to know any other configuration details. See here for details:

    http://static.springsource.org/sprin...jpa-setup-jndi

    You will have to consult your web/application server's documentation to see how to deploy a DataSource and/or an EntityManagerFactory (I know that JBoss can automatically create the latter for you if you add a particular property to persistence.xml).

    Comment


    • #3
      Thanks Andrew.

      I will try the JNDI solution like you suggested.

      Comment


      • #4
        You can try to put your database.properties file outside the jar, in an external folder, and configuring that folder to be in the classpath: using java -classpath or java -Djava.class.path or something similar.

        Since the application will try to scan the location configured in the applicationContext.xml: <contextroperty-placeholder location="classpath*:META-INF/spring/*.properties"/> you can either create this path in your external folder or modify this line for including the path inside your configured external classpath folder.

        If you have a copy of this file in the test/resources, the JUnit will work both with maven and in your IDE. Alternatively you can configure the classpath tab in the run configurations within your IDE for JUnit and Java Applications.

        There is a classpath tab too for the TC Server (double click it and select "Open launch configuration") for your local server testing.

        Comment

        Working...
        X