I'm working on a spring application that contains submodules, roughly looking like the following:
project
|-- module1
| |-- src
| | `-- main
| | |-- java
| | `-- resources
| | |-- applicationContext.xml
| | `-- web.xml
| `-- pom.xml
|-- module2
| |-- src
| | `-- main
| | |-- java
| | `-- resources
| | `-- batch-jobs.xml
| `-- pom.xml
`-- pom.xml
module1 contains the web app configuration.
module2 contains using spring-batch
to run batch jobs, which are configured in batch-jobs.xml
.
Inside applicationContext.xml
I have the following line:
<import resource="classpath*: batch-jobs.xml" />
As far as I can tell, this file is being loaded. I assume this because previously I was using classpath: batch-jobs.xml
(without the *
) and it couldn't find the file.
In spite of loading this file, I get a NoSuchBeanDefinitionException
. If I copy everything from batch-jobs.xml
over to applicationContext.xml
, it works fine.
When you use the asterix like this
<import resource="classpath*: batch-jobs.xml" />
it ignores files it can't find (among other things)
See e.g. this question for details
Make sure you refer to its spring configuration xml with leading slash, like this:
<import resource="classpath:/batch-jobs.xml" />
If it still complains about file batch-jobs.xml not found make sure you have module 2 jar on your classpath (add dependency on module2 to module 1).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With