【spring头文件之简单介绍】

applicationContext.xml为我们常用的spring配置文件。

其中xml中包括了一些头信息,现在简单介绍一下

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"
       default-lazy-init="true">
       
       

</beans>

其实,你可以理解这些是格式性文件,只有引入了.xsd才能用其中的标签,用alt+ /回头提示。

xsd里面的标签里面有子标签

比如aop的配置,只能用下面的几个配置

 <aop:config><aop:advisor advice-ref=""/></aop:config>
       <aop:config><aop:aspect></aop:aspect></aop:config>
       <aop:config><aop:pointcut expression="" id=""/></aop:config>

对应的xsd 如下:

 

-<xsd:element name="config">


-<xsd:annotation>


-<xsd:documentation>

-<![CDATA[
	A section (compartmentalization) of AOP-specific configuration (including
	aspects, pointcuts, etc).
			]]>
</xsd:documentation>

</xsd:annotation>


-<xsd:complexType>


-<xsd:sequence>


-<xsd:element name="pointcut" maxOccurs="unbounded" minOccurs="0" type="pointcutType">


-<xsd:annotation>


-<xsd:documentation>

-<![CDATA[
	A named pointcut definition.
						]]>
</xsd:documentation>

</xsd:annotation>

</xsd:element>


-<xsd:element name="advisor" maxOccurs="unbounded" minOccurs="0" type="advisorType">


-<xsd:annotation>


-<xsd:documentation source="java:org.springframework.aop.Advisor">

-<![CDATA[
	A named advisor definition.
						]]>
</xsd:documentation>

</xsd:annotation>

</xsd:element>


-<xsd:element name="aspect" maxOccurs="unbounded" minOccurs="0" type="aspectType">


-<xsd:annotation>


-<xsd:documentation>

-<![CDATA[
	A named aspect definition.
						]]>
</xsd:documentation>

</xsd:annotation>

</xsd:element>

</xsd:sequence>

你可以理解他就是定义格式的文件,我spring只能配置这些格式。

软件有一句话,约定优于配置,人家约定好了,你照着做就行。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

知乎关注八戒来了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值