相关疑难解决方法(0)

想法避免spring.handlers/spring.schemas在单个jar中合并多个spring依赖项时会被覆盖

我得到了错误Unable to locate NamespaceHandler when using context:annotation-config运行(java -jar)一个由maven-assembly-plugin组装并包含我的项目及其所有依赖项的jar.

正如其他人在forum.springsource.org 线程(消息#7/8)上正确发现的那样,问题出现是因为文件META-INF/spring.handlersMETA-INF/spring.schemas存在于不同的jar中,当maven-assembly-plugin在单个文件中重新打包jar时会被覆盖.

查看两个spring - *.jar文件的内容,您可以看到文件位于相对于类路径的相同位置

$ jar tf spring-oxm-3.0.3.RELEASE.jar
META-INF/spring.handlers
META-INF/spring.schemas
org/springframework/oxm/GenericMarshaller.class
...

$ jar tf spring-context-3.0.3.RELEASE.jar
META-INF/spring.handlers
META-INF/spring.schemas
org/springframework/context/ApplicationContext.class
Run Code Online (Sandbox Code Playgroud)

是不是可以将META-INF文件夹放在特定的包中?如果是这样,我建议的想法(希望它是适用的)是将META-INF/spring.shemasMETA-INF/spring.handlers文件放在他们引用的包下面.

$ jar tf spring-oxm-3.0.3.RELEASE.jar
org/springframework/oxm/META-INF/spring.schemas
org/springframework/oxm/META-INF/spring.handlers
org/springframework/oxm/GenericMarshaller.class
...

$ jar tf spring-context-3.0.3.RELEASE.jar
org/springframework/context/META-INF/spring.handlers
org/springframework/context/META-INF/spring.schemas
org/springframework/context/ApplicationContext.class
Run Code Online (Sandbox Code Playgroud)

这样,在单个jar中合并时它们不会发生冲突.你怎么看待这件事?

spring meta-inf maven-assembly-plugin

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

需要了解spring.handlers和spring.schemas

我有一些问题来自我已经通过另一个问题解决的问题.但是,我仍然想知道根本原因.我的问题如下:

  1. spring.handlersspring.schemas的目的是什么?

据我所知,这是一种告诉Spring Framework在哪里找到xsd以便所有内容都正确连线和加载的方法.但...

  1. 在什么情况下我应该在META-INF文件夹下有这两个文件?

  2. 在我上面链接的另一个问题中,是否有人知道为什么我必须maven-shade-plugin在META-INF下添加创建这两个文件(基于我所有的依赖项)?换句话说,导致我必须使用maven shade插件的根本原因是什么?

spring xsd uri spring-batch spring-3

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

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

任何想法,什么可能导致此错误?

org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法找到XML架构命名空间的Spring NamespaceHandler [http://www.springframework.org/schema/data/jpa]攻击资源:ServletContext资源[/ WEB- INF /弹簧/ appServlet/servlet的context.xml中]

这是我的'servle-context.xml'(缩进有一些问题,但文件太大了......):

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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/beans 
                    http://www.springframework.org/schema/beans/spring-beans-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
                    http://www.springframework.org/schema/context 
                    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to …
Run Code Online (Sandbox Code Playgroud)

java spring maven-3

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