A方式
B方式比A方式少个*
两个配置只有一个字符之差,项目启动时使用B方式就启动不了,报service未加载
实际使用B方式,在spring里为精确匹配,不能匹配通配符,A方式才可以配匹通配符。
原文
传送门
4.7.2.2. The classpath*: prefix
When constructing an XML-based application context, a location string may use the special classpath*: prefix:
ApplicationContext ctx =
new ClassPathXmlApplicationContext("classpath*:conf/appContext.xml");
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.
[Note] Classpath*: portability
The wildcard classpath relies on the getResources() method of the underlying classloader. As most application servers nowadays supply their own classloader implementation, the behavior might differ especially when dealing with jar files. A simple test to check if classpath* works is to use the classloader to load a file from within a jar on the classpath: getClass().getClassLoader().getResources("<someFileInsideTheJar>"). Try this test with files that have the same name but are placed inside two different locations. In case an inappropriate result is returned, check the application server documentation for settings that might affect the classloader behavior.
The "classpath*:" prefix can also be combined with a PathMatcher pattern in the rest of the location path, for example "classpath*:META-INF/*-beans.xml". In this case, the resolution strategy is fairly simple: a ClassLoader.getResources() call is used on the last non-wildcard path segment to get all the matching resources in the class loader hierarchy, and then off each resource the same PathMatcher resoltion strategy described above is used for the wildcard subpath.
<import resource="classpath*:config/**/spring*.xml" />
B方式比A方式少个*
<import resource="classpath:config/**/spring*.xml" />
两个配置只有一个字符之差,项目启动时使用B方式就启动不了,报service未加载
实际使用B方式,在spring里为精确匹配,不能匹配通配符,A方式才可以配匹通配符。
原文
传送门
引用
4.7.2.2. The classpath*: prefix
When constructing an XML-based application context, a location string may use the special classpath*: prefix:
ApplicationContext ctx =
new ClassPathXmlApplicationContext("classpath*:conf/appContext.xml");
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.
[Note] Classpath*: portability
The wildcard classpath relies on the getResources() method of the underlying classloader. As most application servers nowadays supply their own classloader implementation, the behavior might differ especially when dealing with jar files. A simple test to check if classpath* works is to use the classloader to load a file from within a jar on the classpath: getClass().getClassLoader().getResources("<someFileInsideTheJar>"). Try this test with files that have the same name but are placed inside two different locations. In case an inappropriate result is returned, check the application server documentation for settings that might affect the classloader behavior.
The "classpath*:" prefix can also be combined with a PathMatcher pattern in the rest of the location path, for example "classpath*:META-INF/*-beans.xml". In this case, the resolution strategy is fairly simple: a ClassLoader.getResources() call is used on the last non-wildcard path segment to get all the matching resources in the class loader hierarchy, and then off each resource the same PathMatcher resoltion strategy described above is used for the wildcard subpath.
发表评论
-
charles4.2下载与破解方法以及配置https
2020-02-26 09:03 2有两个抓包工具 一个是fidder,一个是charles,两个 ... -
序列号批量生成算法
2019-12-05 14:11 0业务处理过程当中,经常需要生成订单号、序列号等,简单的可 ... -
使用ANTLR处理文本
2019-08-28 17:32 768引用 使用 Antlr 处理文本 https://www.ib ... -
解决maven-metadata.xml文件下载卡死问题
2019-04-11 14:02 3986http://192.168.1.110:8081/nexus ... -
rsync备份和删除指定文件
2018-01-02 10:23 2053文件异地备份时,需要将本地文件合并到服务器上,且不能删除服务器 ... -
javaLocale格式化日期和数字
2017-08-25 09:26 871public static void main(Strin ... -
centos6 tomcat 启动脚本 tomcat服务
2017-08-23 11:24 1441系统自动启动tomcat 复制该脚本到/etc/init.d/ ... -
win7 命令行改IP和DNS
2016-12-21 18:35 738使用管理员权限运行CMD //改DNS netsh ... -
jenkins中集成sonar,使用findbug、pmd、checkstyle提升代码质量
2016-09-29 14:58 6175实际上jenkins单独也 ... -
jenkins 集成sonar
2016-09-18 10:14 0jenkins集成sonar可以从插件中心直接更新安装 son ... -
activeMQ5.14权限配置
2016-08-17 13:47 2673activeMQ默认的消息队列没有用户名和密码,可以直接通过T ... -
solaris 使用解压版的jdk
2016-07-27 15:17 764solaris上配置jdk其实也很简单 由于solaris有 ... -
solaris tomcat开机启动
2016-07-27 16:17 621创建文件夹/var/svc/manifes ... -
HibernateTemplate Vs HibernateDaoSupport Vs Direct Hibernate Access
2016-07-26 11:07 735http://forum.spring.io/forum/sp ... -
spring mvc mybatis will not be managed by Spring
2016-07-20 17:30 9887项目运行时发现事务提交不完整,回滚时只能回滚一半。 系统配置 ... -
java里判断一点是否在某个区域
2016-06-03 17:47 1845import java.awt.geom.Path2D ... -
12306的技术升级
2016-04-20 16:17 1034升级的核心是余票查询的升级,余票查询使用存储过程,sybase ... -
工作流的123
2016-04-20 12:58 577三分钟了解Activity工作流 工作流一般会给开发人员提供流 ... -
sping mvc 使用@Value注解为controller注入值
2016-04-17 17:39 10836spring mvc 里有两个配置文件, 第一个,为sprin ... -
googleapis.com域名访问慢的解决办法
2016-04-13 12:09 9741、安装火狐 2、安装插件ReplaceGoogleCDN
相关推荐
**通过`import`标签引入其他配置文件**:在`spring-mvc.xml`中使用`<import resource="user_spring.xml"/>`引入其他配置文件。 2. **在`web.xml`中配置**:可以在`web.xml`中指定`contextConfigLocation`参数来...
Resource[] resources = resolver.getResources("classpath*:META-INF/INDEX.LIST"); Assert.assertTrue(resources.length > 1); //将加载多个模式匹配的Resource resources = resolver.getResources(...
1. **添加依赖**:在项目中,你需要引入 CXF 和 Spring 相关的库。在 Maven 或 Gradle 的配置文件中,添加相应的依赖项,确保 CXF 和 Spring 框架的版本兼容。 2. **创建服务接口**:定义你的 Web 服务接口,通常是...
4. **统一管理**:整合后,所有服务的配置、管理和监控都可以在Spring容器中进行,降低了复杂性。 总结来说,CXF与Spring的整合为Java Web服务开发提供了更强大的工具和更高效的开发模式,让开发者能够更专注于业务...
- **面向接口编程**:Spring鼓励开发者使用接口而非具体实现类来编写代码,这样可以提高代码的灵活性和可扩展性。例如,在使用Spring时,开发者可以通过定义接口并为其提供不同的实现,从而在运行时根据需要轻松地...
- **简化配置**:减少用户配置MyBatis和Spring环境所需的样板代码。 - **透明事务管理**:增加Spring对MyBatis事务的透明支持,简化事务管理逻辑。 - **异常转换**:将MyBatis异常转换为Spring的`...
import org.springframework.core.io.ClassPathResource; ClassPathResource resource = new ClassPathResource("applicationContext.xml"); BeanFactory factory = new XmlBeanFactory(resource); ``` #### ...
4. **Spring配置**:在Spring XML配置文件(如`applicationContext.xml`)中,你需要声明CXF的Bus和WebServiceEndpoint。例如: ```xml <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource=...
<import resource="classpath:META-INF/cxf/spring/cxf-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/spring/cxf-servlet.xml" /> <jaxws:endpoint id="helloServiceEndpoint" implementor=...
<import resource="classpath*:context/applicationContext-dataAccess.xml"/> <import resource="classpath*:service/applicationContext-*.xml"/> <import resource="classpath*:dao/applicationContext-*.xml...
1. **引入依赖**:首先,在项目中添加CXF和Spring的相关依赖库。 2. **配置CXF**:在Spring配置文件中,定义CXF的Bus实例,配置服务端点(Endpoint)和服务器(Server)。 3. **服务发布**:通过Spring的`jaxws:...
- **Spring框架**:spring.jar - **Struts2核心及插件**:struts2-core-2.0.11.2.jar、struts2-spring-plugin-2.0.11.2.jar - **XWork核心库**:xwork-2.0.5.jar - **其他工具类**:classes12.jar、ognl-2.6.11.jar ...
2. **创建Spring配置**:在Spring的XML配置文件中,你需要声明CXF的Servlet和Bus实例。Servlet将处理HTTP请求,而Bus是CXF的核心,负责管理服务和服务端点。 ```xml <import resource="classpath:META-INF/cxf/...
3. **启用Spring与CXF的整合**:CXF提供了Spring模块,允许我们在Spring应用上下文中直接发布和消费Web服务。通过引入相应的CXF Spring库,可以在配置文件中声明CXF的SpringBus,以启用两者之间的集成。 ```xml ...
Spring提供了`ClassPathResource`类,可以用来加载类路径下的资源,包括jar包内的文件。例如,如果你的jar包名为`mylib.jar`,配置文件为`myconfig.xml`,你可以这样加载: ```java Resource resource = new Class...
1. **安装与配置JDK**:确保你的系统上已经安装了对应版本的JDK,并且环境变量配置正确,包括`JAVA_HOME`和`PATH`。 2. **获取CXF库**:你可以从Apache CXF的官方网站下载CXF的最新版本。解压缩后,将CXF的jar文件...
4. **配置Spring MVC**:在Spring的配置文件(如`spring-servlet.xml`)中,你需要配置CXF的Servlet和WebService服务: ```xml <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource=...