我想使用Maven Dendenpent Project的spring context-xml

时间:2012-05-10 04:36:37

标签: xml spring maven

我有两个项目,每个项目在各自的资源文件夹中都有Spring XML文件。

但是其他项目引用了一个项目,例如导入jar。

如何在jar中使用XML?

2 个答案:

答案 0 :(得分:2)

您可以使用classpath*:/application-context.xml - 将application-context.xml替换为您的文件名。

如果您的Spring XML文件名为applicaiton-context.xml,则将其移至两个项目中的文件夹spring下。然后,您可以使用这两个XML文件创建上下文

ApplicationContext ctx = new ClasspathXmlApplicationContext("classpath*:/spring/application-context.xml")

答案 1 :(得分:0)

您可以使用jar中的xml和项目中的xml:

ApplicationContext context = new ClassPathXmlApplicationContext( new String[] {
                "classpath*:spring/applicationContext-*.xml"});

在此处查看我的Question1Question2