Spring classpath前缀差异 [英] Spring classpath prefix difference

查看:120
本文介绍了Spring classpath前缀差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

记录这里它声明


这个特殊的前缀指定所有
类路径资源与给定的
匹配name必须获得
(在内部,这实际上是通过ClassLoader.getResources(...)
调用发生
),然后合并形成
最终应用程序上下文定义。


有人可以解释一下吗?



使用 classpath *:conf / appContext.xml 相比有什么区别? > classpath:conf / appContext.xml 没有星号。

解决方案

SIMPLE DEFINITION <这是所有appContext.xml文件 conf 类路径中所有jar中的文件夹将被选中并加入一个大的应用程序上下文。



相比之下, classpath:conf / appContext.xml 将加载只有一个这样的文件 ...第一个在你的文件中找到classpath。


Documented here it states

This special prefix specifies that all classpath resources that match the given name must be obtained (internally, this essentially happens via a ClassLoader.getResources(...) call), and then merged to form the final application context definition.

Can someone explain this?

What is the difference between using classpath*:conf/appContext.xml as opposed to classpath:conf/appContext.xml without the asterisk.

解决方案

SIMPLE DEFINITION

The classpath*:conf/appContext.xml simply means that all appContext.xml files under conf folders in all your jars on the classpath will be picked up and joined into one big application context.

In contrast, classpath:conf/appContext.xml will load only one such file... the first one found on your classpath.

这篇关于Spring classpath前缀差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆