0

My maven top level project refers to a common-db project. In this project I have a spring file which defines the DB parameters.

However, I want the top-level project to define the DB parameters through the profile and inject these into the spring config file in /src/main/resources.

The top-level project only does the filtering on its own /src/main/resources files and ignores those located in the JAR dependencies.

How can I do this?

DD.
  • 21,498
  • 52
  • 157
  • 246
  • 1
    put your top-level spring config file into the same classpath location, so it overrides corresponding common-db project file – hoaz May 22 '13 at 16:24
  • I dont want to have any config file in the top level project. This is already defined in the common-db project. I have several projects referencing the db project and want this config in one place instead of several. – DD. May 22 '13 at 16:30

1 Answers1

0

So you want to depend on common-db but then modify its contents to change the parameters in the config file? Ok, if you really want to do that, you could do something convoluted where you use dependency:unpack to expand the common-db jar, then overwrite / filter its contents, and then use a custom jar:jar execution to re-jar up the dependency and ship it with your application.

But, wow - why would you jump through all these hoops? Like @hoaz suggested, just place your application-specific config in the same classpath location so that it is loaded before common-db's default configuration. This is the convention followed by many, many Java libraries.

noahlz
  • 10,202
  • 7
  • 56
  • 75