IntelliJ IDEA validates toward wrong XSD

前端 未结 2 804
一向
一向 2021-01-03 09:37

I have defined the following transaction manager:

    

and

相关标签:
2条回答
  • 2021-01-03 10:22

    If you open up the jar file that the schemaLocation should point to the xsd according to this screen shot:

    enter image description here

    Then you'll see that IntelliJ has a bunch of xsd files for different versions of Spring:

    enter image description here

    This means that you really have all the schemas you need.

    If your bean definitions file has problems then your schemaLocation must point to the wrong version in the Spring jar file:

    enter image description here

    Check the Settings | Schemas and DTDs and verify that you haven't accidentally manually set it to point to the wrong xsd file:

    enter image description here enter image description here

    If it is wrong then you'll have to remove that line using the minus sign. This will cause IntelliJ to go back to it's default values:

    enter image description here

    After that you should be seeing the same thing as in the first screen shot.

    0 讨论(0)
  • 2021-01-03 10:37

    I was having a similar problem trying to use spring security and beans in the same xml config. IntelliJ was insisting on validating using the security xsd version 2.0 despite everything telling it to use version 3.1.

    I was able get IntelliJ to figure it out by changing the default namespace between security and beans.

    I originally had:

    <beans:beans xmlns="http://www.springframework.org/schema/security"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:beans="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
    

    So I switched it to:

    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:security="http://www.springframework.org/schema/security"
           xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
    

    After that IntelliJ was validating using the correct xsd. I'm not sure if this was a bug with IntelliJ or something I was doing wrong, but it works now.

    Hopefully this helps someone in the future.

    0 讨论(0)
提交回复
热议问题