添加 spring-data-jpa 架构引用后 Spring 配置 xml 无效

2023-12-24

启动 spring 上下文时出现以下异常:

java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/; lineNumber: 1; columnNumber: 55; White spaces are required between publicId and systemId.

在我将 spring-data-jpa 添加到 spring config.xml 之前,一切正常。为什么 xml 不再有效?

弹簧配置.xml

<?xml version="1.0" encoding="UTF-8"?>
<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:aop="http://www.springframework.org/schema/aop" 
       xmlns:tx="http://www.springframework.org/schema/tx" 
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xsi:schemaLocation="http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/data/jpa
        http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <context:property-placeholder location="classpath:application.properties" />

    <context:component-scan base-package="com.example" />

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/jsp/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

    <!-- set up JPA and transaction config -->
    <tx:annotation-driven transaction-manager="transactionManager" />

    <!-- spring data jpa with JpaRepository -->
    <jpa:repositories base-package="com.example.repositories" />

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}"/>    
    </bean>
    <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="showSql" value="${hibernate.show_sql:false}"/>
        <property name="generateDdl" value="true"/>
        <property name="database" value="MYSQL"/>
    </bean>
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
        <!-- spring based scanning for entity classes-->
        <property name="packagesToScan" value="com.example.entities"/>
    </bean>

    <bean id="transactionManager"  class="org.springframework.orm.jpa.JpaTransactionManager" />
</beans>

请重新排序以下行:

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

..对此:

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

这正是您的错误消息所指向的位置,以及成对的外观(namespace location) is relevant http://www.w3.org/TR/xmlschema-1/#schema-loc!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

添加 spring-data-jpa 架构引用后 Spring 配置 xml 无效 的相关文章

随机推荐

  • 如何获取两个日期之间的所有产品?

    如何获取两个日期之间的所有产品 例如上个月产品 本月产品 上周产品和本周产品等 我尝试过这个 current day to start with start mktime 0 0 0 date m date d date Y calcula
  • 使用父宏的右括号的 C 预处理器

    我有这个有效的代码 include
  • gRPC Python thread_pool 与 max_concurrent_rpcs

    当启动Python时grpc server 有什么区别maximum concurrent rpcs和max workers在线程池中使用 如果我愿意maximum concurrent rpcs 1 我还应该向线程池提供多个线程吗 换句话
  • 域名已与“现有”CloudFront 分配关联

    当我尝试通过设置域时无服务器域管理器 https github com amplify education serverless domain manager with sls create domain 失败并显示 BadRequestE
  • 进行输出重定向

    我想将 make 命令的输出和错误流重定向到文件 以下命令 make 1 gt 2 tmp build log 抛出以下错误 make Nothing to be done for Users m tmp build log EDIT Tr
  • 这很可能是瞬态情况,可以通过后退重试来纠正

    我在我的项目中使用 firebase 并且遇到了下面提到的一些问题 cloud firestore unavailable 该服务当前不可用 这很可能是一种瞬态情况 可以通过后退重试来纠正 我正在使用 firebase lib 版本 fir
  • HttpClient 将 byte[] 发送到 WCF 服务会产生错误:最大数组长度配额 (16384) 或最大项目数

    我有一个 WCF 服务可以接受byte 我正在使用创建一个客户端HttpClient并收到以下错误 我在网上读到你必须设置readerQuotas在服务器和客户端上 但是如何在服务器上设置这些设置HttpClient Error 反序列化
  • Perl 中@_ 的含义是什么?

    是什么意思 在 Perl 中 佩尔多克 佩尔瓦尔 http perldoc perl org perlvar html ARG是检查任何特殊命名的 Perl 变量信息的第一个地方 Quoting 子程序内的数组 包含传递给该子例程的参数 更
  • 如何添加排名栏?

    我想选择记录并确定每个相似数据的排名号 我的数据如下 MEMBER ID LOAN AMOUNT 1 2 000 00 2 1 000 00 3 4 000 00 4 1 000 00 我想要的结果如下所示 RANK MEMBER ID L
  • 使用 netlink API 设置无线通道

    我正在Ubuntu Linux 12 04环境中开发WiFi工具 我需要在不同通道之间切换WiFi接口 目前 我在 Wireshark 源代码 ws80211 utils c 中名为 ws80211 set freq 的函数中找到了解决方案
  • FPDF 错误:此文档(mine.pdf)可能使用了 FPDI 附带的免费解析器不支持的压缩技术[重复]

    这个问题在这里已经有答案了 如何解决问题 制作模板时 使用 PDF A 1a 导出设置将其导出 在 Acrobat Pro 中 您可以使用此设置另存为 更多详细信息 MAC OS X 但也应该适用于 WIN 在 acrobat pro 中打
  • Touchenter 和 touchleave 事件支持

    我读到了有关 touchenter 和 touchleave 事件的信息 位于莫兹拉网站 https developer mozilla org en US docs Web API TouchEvent and w3网站 http www
  • 如何在 PHP 中设置深度数组

    假设我有以下功能 function setArray array key value array key value 上面的函数中 key只在第一层 如果我想在第二层或第三层设置key 如何重写函数 e g array foo bar te
  • 如何查看初始化权重(即训练前)?

    我正在使用 Keras 生成一个简单的单层前馈网络 当通过以下方式初始化权重时 我想更好地处理权重的值kernel initializer争论 有没有办法可以在初始化后 即训练完成之前 查看权重值 只需使用get weights 在模型上
  • 包含字符串文字的文档测试

    我有一个单元测试 我想为一个将 XML 作为字符串的函数编写 这是一个文档测试 我希望 XML 与测试一致 由于 XML 是多行的 我在文档测试中尝试了字符串文字 但没有成功 这是简化的测试代码 def test gt gt gt conf
  • Excel VBA 合并/组合具有相同名称的列

    我的项目工作存在类似于下面描述的问题 My dataset is like this What I want is like this LAST COLUMN 我拥有的是许多同名的列 例如 Is paid Job 我想要的是创建一个新列 T
  • 数据库不存在错误

    当我进行数据库备份时 出现数据库不存在的错误 但我可以正常附加数据库 并且其他进程 例如数据插入和更新 工作正常 但是当我进行数据库备份时 出现以下错误 我显示了错误屏幕截图和备份按钮代码 string cnstr Data Source
  • PHP 服务器发送事件连接不会关闭?

    我已经实施了一个服务器发送事件 https developer mozilla org en US docs Web API Server sent events with 事件源 https developer mozilla org e
  • 从函数返回包含单个项目的元组

    刚刚在 Python 中遇到了一点奇怪的地方 我想我应该记录它在这里将其写为一个问题 以防其他人试图使用与我相同的徒劳搜索词来找到答案 看起来元组解包可以做到这一点 因此如果您希望迭代返回值 则无法返回长度为 1 的元组 虽然看起来外表是骗
  • 添加 spring-data-jpa 架构引用后 Spring 配置 xml 无效

    启动 spring 上下文时出现以下异常 java lang Exception java lang IllegalStateException ContainerBase addChild start org apache catalin