Spring xml configuration schema validation error

I have a project using Spring (context, transaction, apect) 4.1.6.RELEASE and spring -data-jpa 1.8.0.RELEASE and some strange errors that are supposedly caused by xsd checking. However, I cannot understand the reason. Oddly enough, projects work fine, all my beans are correctly recognized.

I am using the Eclipse luna and Spring Tools Suite plugin

I removed everything from my applicationContext.xml, except for the string "jpa:", which causes problems. Xml was created using the STS plugin.

I tried to remove version numbers from xsds without success.

enter image description here

+5
source share
3 answers

I encountered the same problem a while ago, all errors were caused by jpa thing I moved the jpa configuration to a new configuration file

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" default-destroy-method="destroy" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd"> <context:component-scan base-package="com.some.validator" /> <context:component-scan base-package="com.some.security.rest" /> <jpa:repositories base-package="com.some.repository.path" entity-manager-factory-ref="entityManagerFactory" /> </beans> 

some maven import:

  <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> <version>1.8.2.RELEASE</version> </dependency> 

and spring version of the frame

  <org.springframework-version>4.1.7.RELEASE</org.springframework-version> 

Try cleaning the project and updating it with maven

+2
source

I had the same problem as you, and it came from versions of xsd files. In particular, the problem disappeared when I uninstall the Spring Context XSD version.

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> <jpa:repositories base-package="com.app.repositories" /> </beans> 

This XML file does not create any validation error for me.

Greetings

Emmanuel

+1
source

To fix these XML validation issues, you can completely remove version notations, as shown below, and let Spring load general schema locations.

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schem...ng-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schem...spring-jpa.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"> 

Enabling shared schema locations or an XSD version does not produce different results for application behavior. Also, try reorganizing pom.xml and make sure that the time dependencies have been resolved with the correct version.

The strange part of this permission is that it worked for me in several applications, but did not work in others, where I received the same error. For me, sometimes changing the ed-version of XSDs to a generic one, and then changing them back to version again, worked out. Eclipse Luna-tic behavior!

PS: No offense intended for fans of Eclipse.

+1
source

Source: https://habr.com/ru/post/1234846/


All Articles