1

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.

enter image description here

If I add this jar, warn will disappear.

enter image description here

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

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Shuai Li
  • 2,426
  • 4
  • 24
  • 43

2 Answers2

0

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.

enter image description here

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

Bajal
  • 5,487
  • 3
  • 20
  • 25
0

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:

kjhughes
  • 106,133
  • 27
  • 181
  • 240