相关疑难解决方法(0)

无法找到XML模式命名空间的Spring NamespaceHandler http://www.springframework.org/schema/data/jpa

我在我的java项目中使用spring和hibernate,它由maven管理.我使用以下命令创建了一个程序集(带有依赖项的jar)mvn install assembly:assembly

现在,当我尝试使用命令运行我的主类时:java -cp xyz-1.0-SNAPSHOT-jar-with-dependencies.jar com.xyz.class然后我收到以下错误:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/data/jpa]**
Offending resource: class path resource [xyz-component-scans-config.xml]

    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:271)
.
.
Run Code Online (Sandbox Code Playgroud)

我不明白为什么它无法找到NamespaceHandler?因为我已经在pom中有以下依赖项.

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>3.1.0.RELEASE</version
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-jpa</artifactId>
      <version>1.0.2.RELEASE</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency> 
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>3.1.0.RELEASE</version>
      <scope>compile</scope>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

我确实尝试了以下主题中的建议,但它对我不起作用. 无法找到XML架构命名空间的Spring NamespaceHandler [http://www.springframework.org/schema/data/jpa]

org.springframework.beans.factory.parsing.BeanDefinitionParsingException的源代码

java spring maven spring-data-jpa

14
推荐指数
2
解决办法
1万
查看次数

无法找到XML架构命名空间的Spring NamespaceHandler [http://www.springframework.org/schema/batch]

情况

我正在使用Spring Batch为我们的数据仓库构建累积快照,我遇到了一个我无法弄清楚的配置障碍.

我使用Spring模板项目使用STS(SpringSource Tool Suite 2.8.1)创建了一个简单的Spring Batch 项目.这些是我创建的两个xml配置文件:

发射后的context.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:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="
    http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
    http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

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

<context:component-scan base-package="edu.kdc.visioncards" />

<jdbc:initialize-database data-source="dataSource">
    <jdbc:script location="${batch.schema.script}" />
</jdbc:initialize-database>

<batch:job-repository id="jobRepository" />

<import resource="classpath:/META-INF/spring/module-context.xml" />
Run Code Online (Sandbox Code Playgroud)

module-context.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:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<description>Example job to get you started. It provides a skeleton for a typical batch application.</description>

<batch:job id="job1">
    <batch:step …
Run Code Online (Sandbox Code Playgroud)

spring spring-batch

12
推荐指数
1
解决办法
4万
查看次数

Spring如何从类路径中找到XSD文件

在我们的spring配置中,我们将beans标记放在这样:

<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"
    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.xsd">
Run Code Online (Sandbox Code Playgroud)

现在spring必须从我的calsspath中找到文件的位置 spring-beans.xsd&spring-context.xsd.

我在这条路径上找到了一些xsd文件:

弹簧上下文4.1.5.RELEASE.jar /组织/ springframework的/上下文/配置

spring-context-2.5.xsd
spring-context-3.0.xsd
spring-context-3.1.xsd
spring-context-3.2.xsd
spring-context-4.0.xsd
spring-context-4.1.xsd
Run Code Online (Sandbox Code Playgroud)

在搜索spring-beans.xsd文件时,我在这条路径中找到了一些文件:

弹簧豆-4.1.5.RELEASE.jar /组织/ springframework的/豆/工厂/ XML

spring-beans-2.5.xsd
spring-beans-3.0.xsd
spring-beans-3.1.xsd
spring-beans-3.2.xsd
spring-beans-4.0.xsd
spring-beans-4.1.xsd
Run Code Online (Sandbox Code Playgroud)

spring如何知道在哪里查找此文件,因为我的beans标记中的模式位置与此文件的实际位置之间没有链接.此外,我能够找到这样的文件spring-beans-<version>.xsd然后spring-beans.xsd当我们没有在<beans>标签中指定任何版本时,Spring将如何知道甚至是什么.

java xml spring xsd

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

spring ×3

java ×2

maven ×1

spring-batch ×1

spring-data-jpa ×1

xml ×1

xsd ×1