简体   繁体   中英

How does xsi:schemaLocation work with IntelliJ IDEA?

I am a little confused with how does xml xsi:schemaLocation works.

I am using Maven + IDEA to create a Spring project.

If miss org.springframework.spring-beans in my dependency, IDEA will warn me some error.

在此处输入图片说明

If I add this jar, warn will disappear.

在此处输入图片说明

Maybe it is not important, but it like a black magic to me, can any one help me how does this work?

Those XSDs are in fact included in the jar provided by spring. You can check this by doing a double shift and typing in the XSD's filename. So if you don't include the jar, your maven project cannot locate the XSD in your classpath.

在此处输入图片说明

The XSD you mentioned can be found here , as part of the spring-beans module

IntelliJ IDEA is helpfully indicating that it cannot location the XSD that it needs to validate the Spring project.

It turns the default namespace ( beans/@xmls ) red because it uses that along with the paired value of the namespace given by xsi:schemaLocation (also red) in order to find the governing XSD. Note that this does not necessarily have to be at the URL given by the paired value xsi:schemaLocation ( https://www.springframework.org/schema/beans/spring-beans.xsd ). Other mechanisms, including as XML Catalogs, can aid in the resolution of where the actual XSD can be found.

In this case, IDEA knows to check JARs on the classpath for the needed XSD.

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM