开发者

Is the "classpath:" prefix specific to Spring, or is this a JVM concept?

开发者 https://www.devze.com 2023-03-13 03:26 出处:网络
I have this in my web.xml: <context-param> <param-name>contextConfigLocation</param-name>

I have this in my web.xml:

<context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>classpath:spring-config.xml</param-value>
</context-开发者_开发知识库param>

I suspect this is a convention used only by Spring? If it is, will it take my app longer to load, since I'm not specifying a direct file location, but now it must search the entire classpath?


I suspect this is a convention used only by Spring?

Yes, it stands for a ClassPathResource and is part of Spring's Resource abstraction

If it is, will it take my app longer to load, since I'm not specifying a direct file location, but now it must search the entire classpath?

No, a) it uses the ClassLoader internally which should be fast enough. b) you don't really have much of a choice. using files is a very bad idea in a webapp context, because it makes you dependent on implementation details that should be left to the implementing App server (a WAR may or may not be unpacked).

0

精彩评论

暂无评论...
验证码 换一张
取 消