[英]Error importing bean definitions inside jar file
I have two project. 我有两个项目。 One is Project-A which contains database operations java codes and spring bean definition xml files.
一个是Project-A,它包含数据库操作java代码和spring bean定义xml文件。 The structure is:
结构为:
resources/base
is source folder and configure
is a package inside that source folder. resources/base
是源文件夹,而configure
是该源文件夹中的软件包。 base-definitions.xml
loads remaining xml files [dao-service-definitions.xml and transaction-definition.xml]
like following. base-definitions.xml
会加载其余的xml文件[dao-service-definitions.xml and transaction-definition.xml]
,如下所示。
base-definitions.xml base-definitions.xml
<import resource="classpath:configure/dao-service-definitions.xml"/>
<import resource="classpath:configure/transaction-definition.xml"/>
Then I built jar file of that project including spring bean definiton files using Ant. 然后,我使用Ant构建了该项目的jar文件,其中包括spring bean definiton文件。 I used
zipfileset
to set xml files directory inside jar file. 我使用
zipfileset
在jar文件中设置xml文件目录。 The structure is same as above picture. 结构与上图相同。
resources\\base\\configure\\[xml files]
build.xml build.xml
<zipfileset dir="../resources/base/configure" includes="*.*" prefix="resources/base/configure" />
In the another Project-B, I imported jar file and set classpath. 在另一个Project-B中,我导入了jar文件并设置了类路径。 Then import
base-definitions.xml
from Project-A into another xml in Project-B. 然后将Project-A中的
base-definitions.xml
导入到Project-B中的另一个xml中。
<import resource="classpath*:**/base-definitions.xml"/>
Problem: 问题:
The problem is base-definitions.xml
is found but can't find definition files imported in that. 问题是找到了
base-definitions.xml
,但是找不到在其中导入的定义文件。
Extracted Errors: 提取的错误:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:**/base-definitions.xml]
Failed to import bean definitions from URL location [classpath:configure/dao-service-definitions.xml]
class path resource [configure/dao-service-definitions.xml] cannot be opened because it does not exist
What am I doing wrong? 我究竟做错了什么? Thank you for your precious time.
谢谢您的宝贵时间。
In base-definitions.xml, I changed the 在base-definitions.xml中,我更改了
<import resource="classpath:configure/dao-service-definitions.xml"/>
<import resource="classpath:configure/transaction-definition.xml"/>
to 至
<import resource="classpath:resources/base/configure/dao-service-definitions.xml"/>
<import resource="classpath:resources/base/configure/transaction-definitions.xml"/>
and it is working now. 现在正在工作。 I found out that, as Project-A is intended to use as jar file in another project, the structure must be absolute path.
我发现,由于Project-A打算在另一个项目中用作jar文件,因此结构必须是绝对路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.