解决spring jpa中配置文件报'jpa:repositories'的问题

简介:

一、问题描述

    使用spring jpa,报no declaration can be found for element 'jpa:repositories'错误的解决方案

    Multiple annotations found at this line:

- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:repositories'. 
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/data/jpa/spring-jpa.xsd',  

because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

    spring配置文件 

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" 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/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.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/spring-jpa.xsd

    修改为

    http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd

    并且加上如下两名:

   http://www.springframework.org/schema/data/repository
   http://www.springframework.org/schema/data/repository/spring-repository-1.6.xsd

   注意:

   不添加后面两句,会报:

Referenced file contains errors (http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd). For more information, right click on the 
 message in the Problems View and select "Show Details..."

三、原因分析:

http://www.springframework.org/schema/data/jpa/spring-jpa.xsd

此文件的确不存在,可以在浏览器中进行验证,而http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd

是存在的,估计是spring-jpa-1.3.xsd 代替了spring-jpa.xsd


目录
相关文章
|
3月前
|
Java Spring
Spring boot 运行服务jar外配置配置文件方式总结
Spring boot 运行服务jar外配置配置文件方式总结
492 0
|
4月前
|
druid Java 关系型数据库
Spring Boot2 系列教程(二十五)Spring Boot 整合 Jpa 多数据源
Spring Boot2 系列教程(二十五)Spring Boot 整合 Jpa 多数据源
|
22天前
|
Java 数据库连接 API
【Java笔记+踩坑】Spring Data JPA
从常用注解、实体类和各层编写方法入手,详细介绍JPA框架在增删改查等方面的基本用法,以及填充用户名日期、分页查询等高级用法。
【Java笔记+踩坑】Spring Data JPA
|
10天前
|
消息中间件 NoSQL 安全
(转)Spring Boot加载 不同位置的 application.properties配置文件顺序规则
这篇文章介绍了Spring Boot加载配置文件的顺序规则,包括不同位置的application.properties文件的加载优先级,以及如何通过命令行参数或环境变量来指定配置文件的名称和位置。
|
2月前
|
安全 Java 数据安全/隐私保护
基于SpringBoot+Spring Security+Jpa的校园图书管理系统
本文介绍了一个基于SpringBoot、Spring Security和JPA开发的校园图书管理系统,包括系统的核心控制器`LoginController`的代码实现,该控制器处理用户登录、注销、密码更新、角色管理等功能,并提供了系统初始化测试数据的方法。
36 0
基于SpringBoot+Spring Security+Jpa的校园图书管理系统
|
2月前
|
Java 关系型数据库 MySQL
|
2月前
|
Java Spring 数据库
怎样动动手指就能实现数据操作?Spring Data JPA背后的魔法揭秘
【8月更文挑战第31天】在Java开发中,数据库交互至关重要。传统的JDBC操作繁琐且难维护,而Spring Data JPA作为集成JPA的数据访问层解决方案,提供了CRUD等通用操作接口,显著减少代码量。通过继承`JpaRepository`,开发者能轻松实现数据的增删改查,甚至复杂查询和分页也不再困难。本文将通过示例详细介绍如何利用Spring Data JPA简化数据访问层的开发,提升代码质量和可维护性。
29 0
|
2月前
|
Java Spring 传感器
AI 浪潮席卷,Spring 框架配置文件管理与环境感知,为软件稳定护航,你还在等什么?
【8月更文挑战第31天】在软件开发中,配置文件管理至关重要。Spring框架提供强大支持,便于应对不同环境需求,如电商项目的开发、测试与生产环境。它支持多种格式的配置文件(如properties和YAML),并能根据环境加载不同配置,如数据库连接信息。通过`@Profile`注解可指定特定环境下的配置生效,同时支持通过命令行参数或环境变量覆盖配置值,确保应用稳定性和可靠性。
41 0
|
2月前
|
存储 Java 数据库
|
2月前
|
存储 Java API
下一篇
无影云桌面