Normal Spring profile template
1 <?xml version= "1.0" encoding= "UTF-8"?> 2 <beans xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance " 3 xmlns=" Http://www.springframework.org/schema/beans " 4 5 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd "> 6 7 </beans>
1 //template format after adding annotations2<beans xmlns= "Http://www.springframework.org/schema/beans"3Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"4xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"5xmlns:tx= "Http://www.springframework.org/schema/tx"6xmlns:context= "Http://www.springframework.org/schema/context"7Xmlns:mvc= "Http://www.springframework.org/schema/mvc"8xmlns:task= "Http://www.springframework.org/schema/task"9xsi:schemalocation="Tenhttp//Www.springframework.org/schema/beans Onehttp//www.springframework.org/schema/beans/spring-beans-3.1.xsd Ahttp//Www.springframework.org/schema/tx -http//www.springframework.org/schema/tx/spring-tx-3.1.xsd -http//WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP thehttp//www.springframework.org/schema/aop/spring-aop-3.1.xsd -http//Www.springframework.org/schema/context -http//www.springframework.org/schema/context/spring-context-3.1.xsd -http//Www.springframework.org/schema/mvc +http//www.springframework.org/schema/mvc/spring-mvc-3.1.xsd -http//Www.springframework.org/schema/task +http//www.springframework.org/schema/task/spring-task-3.1.xsd ">
1 xmlns= "Http://www.springframework.org/schema/beans"2 xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance "
This is a necessary part of the spring configuration file.
Line 1th: Declares the default namespace for the XML file, which represents the default namespace for all labels that do not use other namespaces. <bean id= "" ></bean> default namespace, do not need to prefix <bean:bean id= "";
Line 2nd: Declare an XML SCHEMA instance and declare it to use the SchemaLocation property.
1 xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"
This is the spring configuration file that requires the use of an AOP tag, declaring a namespace prefixed with AOP, and the URL used to indicate the namespace is not used by the parser to find information. Its only function is to give the namespace a unique name. When a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with the same namespace. Then other things like context (for component tags), MVC (for MVC tags), TX (for transaction labels) all mean the same.
1 xsi:schemalaction section: 2 http://Www.springframework.org/schema/beans3 http:// Www.springframework.org/schema/beans/spring-beans-3.1.xsd
is to specify the XSD specification file for the namespace configured above, so that you will be given the following specific configuration of the XSD specification files according to the corresponding hints, such as how each label is written, and some of the properties can be smart hints, in order to prevent errors in the configuration is not easy to troubleshoot, The configuration is also validated against the XSD specification when the service is started. However, it is necessary to configure the XSD specification file for the MVC, AOP, TX, and so on that you configure in the xmlns above.
------------------------------------------------------------------------------------------------------
"Xsi:schemalocation=" Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-3.0.xsd "
Specify a specific version, how do you know which version to use when you write?
In each Xsi:schemalocation property, there is an XSD file with the specified version number, and for a problem with no version number, the default value is used, which essentially has a specific version number. Of course, you can also use a specific version number.
And for these XSD file path lookup methods, you can locate each jar package to find, For example, using a jar package with 4.1.4 version beans, you can open the Spring-beans-4.1.4.release.jar file through Eclipse and open the Meta-inf/spring.schemas file as follows:
As you can see, the default address also has a specific version number, then open the Org/springframework/beans/factory/xml directory according to the following address, as follows:
You can see that the last place to locate the XSD file is to implement the label hint.
Summarize:
The XML schema namespace avoids naming conflicts, like the package in Java, which categorize different roles of labels (such as the TX namespace in spring for a transaction class label, and the context namespace for the label of the component).
Reference:
Https://www.cnblogs.com/EasonJim/p/6880329.html
About header writing for spring configuration files