需要了解 spring.handlers 和 spring.schemas
我有一些问题源于我已经通过 这个其他问题。然而,我仍然想知道根本原因。我的问题如下:
- spring.handlers 和 spring.schemas 的目的是什么?
据我了解,这是一种告诉 Spring 框架在哪里找到 xsd 的方法,以便所有内容都正确连接和加载。但是...
在什么情况下我应该将这两个文件放在 META-INF 文件夹下?
在上面链接的其他问题中,有人知道为什么我必须添加
maven-shade-plugin
才能在 META-INF 下创建这两个文件(基于我的所有依赖项)?换句话说,让我必须使用 Maven Shade 插件的根本原因是什么?
I have some questions derived from a problem that I have already solved through this other question. However, I am still wondering about the root cause. My questions are as follows:
- What is the purpose of spring.handlers and spring.schemas?
As I understand it's a way of telling the Spring Framework where to locate the xsd so that everything is wired and loaded correctly. But...
Under what circumstances should I have those two files under the META-INF folder?
In my other question linked above, does anybody know why I had to add the
maven-shade-plugin
to create those two files (based on all my dependencies) under META-INF? In other words, what was the ROOT CAUSE that made me have to use the maven shade plugin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,你或多或少自己发现了它,让我们添加更多细节:
一些 spring 库包含 spring.schemas 和 META-INF 目录中的 spring.handlers 文件
META-INF/spring.schemas
META-INF/spring.handlers
步骤等。
(*) 实际的重新映射发生在 Spring 应用程序上下文的构建期间
通常这些文件位于您使用的 spring 库 jar 中,但是您可以使用该机制来实现自己的命名空间 bean 解析,那么您将拥有自己的文件
如果您在 spring 配置中使用 spring 命名空间,则需要适当的文件,
当您想要运行 java 应用程序时就会出现问题:
我猜 通常在 war 内您没有使用完整的类路径启动主类,如果您合并,我也更新了您第一个问题的答案
(*)合而为一jar,您必须确保所有 spring.schemas/spring.handlers 文件的内容都合并为一个 spring.schemas 和一个 spring.handlers 文件,请参阅此 答案使用 maven 配置来创建 all-in-one.jar
well you more or less found it out by yourself, let's add some more details:
some spring libraries contain a spring.schemas and a spring.handlers file inside a META-INF directory
META-INF/spring.schemas
META-INF/spring.handlers
step, etc.
(*) the actual re-mapping happens during the build of the spring application context
normally the files are inside the spring library jars you use, but you can use the mechanism to implement own namespace bean parsing, then you would have own files
if you use a spring namespace in your spring configuration, you need the appropriate files
the problem arises when you want to run a java application:
i guess you did not start the mainclass with the complete classpath and i updated my answer for your first question too
(*) if you merge all into one jar, you have to make sure, that the contents of all spring.schemas/spring.handlers files are merged into one spring.schemas and one spring.handlers file, see this answer for a configuration with maven to create an all-in-one.jar