web.xml中classpath:和classpath*: 有什么区别?
有时候会用模糊匹配的方式配置多配置文件。
但是如果配置文件是在jar包里,模糊匹配就找不到了。可以用逗号隔开的方式配置多个配置文件。
如:
contextConfigLocation classpath*:applicationContext.xml, classpath*:app-datasource.xml, classpath*:app-memcached.xml, classpath*:app-ibatis.xml, classpath*:app-rest.xml
contextConfigLocation
classpath:applicationContext.xml
< /context-param>
contextConfigLocation
WEB-INF/applicationContext*.xml
配置web.xml使这2个路径一致:
contextConfigLocation /WEB-INF/classes/applicationContext.xml
contextConfigLocation
classpath*:conf/spring/applicationContext_core*.xml, classpath*:conf/spring/applicationContext_dict*.xml, classpath*:conf/spring/applicationContext_hibernate.xml, classpath*:conf/spring/applicationContext_staff*.xml, classpath*:conf/spring/applicationContext_security.xml classpath*:conf/spring/applicationContext_modules*.xml classpath*:conf/spring/applicationContext_cti*.xml classpath*:conf/spring/applicationContext_apm*.xml
contextConfigLocation 参数定义了要装入的 Spring 配置文件。
contextConfigLocation
classpath*:/applicationContext-*.xml
contextConfigLocation
classpath:/spring/applicationContext-*.xml
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/229682.html原文链接:https://javaforall.net
