在用myeclipse工具进行开发spring的时候,在没有任何资料参考的前提下,如何编写配置文件呢?
下面记录了手工添加XML Schema描述的过程,方便我们创建spring的配置文件:
1、在myeclipse中找到xml的配置项:window--->preferences搜索xml, 找到XML Catalog

2、添加xsd文件
1)下面是从spring官网下载的spring framework压缩包,里边就有所有schema,找到beans
2)location指定的就是spring-beans的xsd文件的位置

3)添加进来后,效果如下图:

3、创建spring的配置文件applicationContext.xml
1)
2)

3)

4)

5)

6)

7)

特别说明:
1、默认xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans " 改成
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "
2、如果不想用p前缀,想直接用<beans></beans>,可向下图一样去掉前缀即可
8)

9)

10)

4、spring配置文件创建成功。
创建配置文件前,添加好spring需要的jar包,这样自然会把spring的除了beans以外的其他命名空间自动引入,需要时勾选即可,很方便。

本文详细记录了在MyEclipse中手工添加XMLSchema描述,创建Spring配置文件的过程,包括设置XMLCatalog、添加xsd文件、创建applicationContext.xml等步骤,并特别说明了配置文件的修改和使用技巧。
749

被折叠的 条评论
为什么被折叠?



