0

I have around 10 xml files to be to imported to main spring config file. All of them have a common string in their name "asset". So their names are like Aasset.xml, Basset.xml and so on ... In my main spring config file, i am importing them as following:

<import resource="classpath*:*asset.xml" />

But this is not working when we package our code into a jar and try to run it. At runtime bean dependencies are not found.

Any ideas on this? I dont want to import files one by one.

Lokesh
  • 7,810
  • 6
  • 48
  • 78
  • How do you package a jar? Maven? Double check if the xml files are in the jar (unzip it). Does importing one by one work? – Piotr Gwiazda Aug 27 '14 at 05:29
  • We use maven and files are present in jar, i have checked that. If i give complete name it works. – Lokesh Aug 27 '14 at 05:31
  • Try classpath: not classpath*: see http://stackoverflow.com/questions/3294423/spring-classpath-prefix-difference Is it a single jar? – Piotr Gwiazda Aug 27 '14 at 05:41
  • @PiotrGwiazda: After changing "classpath*" to "classpath" it is not considering "*" in filename as wildcard entry instead it considers it as part of filename and fails to load it. Yes its a single jar. – Lokesh Aug 27 '14 at 06:40

1 Answers1

0

Try to put all the spring application context files in a file system and then load it

<import resource="classpath*:file://Disk:spring/context/*asset.xml"/>

(Or)

Create a META-INF folder parallel to src then load like the following :

<import resource="classpath*:/META-INF/context/*asset.xml"/>
Ram Kowsu
  • 711
  • 2
  • 10
  • 30