有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

mysql的java Spring数据xml配置

我正在尝试用Spring数据和MySql建立一个项目。在使用tomcat部署应用程序时,我遇到了以下错误:

org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'repository:auditing-attributes' to a(n) 'attribute group' component.

我已按如下方式配置了存储库:

<jpa:repository base-package="com.navin.logging.repositories" />

以下是我的xml配置的顶部:

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

以下是我对Maven的依赖:

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.7.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
</dependency>
<dependency>
     <groupId>org.springframework.data</groupId>
     <artifactId>spring-data-commons-core</artifactId>
     <version>1.4.1.RELEASE</version>
</dependency>
<dependency>
     <groupId>org.springframework.data</groupId>
     <artifactId>spring-data-commons</artifactId>
     <version>1.9.1.RELEASE</version>
</dependency>

非常感谢您的帮助


共 (1) 个答案

  1. # 1 楼答案

    …-commons-core依赖项已过时。最好也删除spring-data-commonsspring-data-jpa无论如何都应该引入所有必要的依赖项

    小提示:在XML配置文件中使用无版本的XSD声明(即spring-context.xsd而不是spring-context-3.0.xsd)。这将防止在模式文件以传递方式包含同一模式文件的其他版本时发生冲突