需要了解spring.handlers和spring.schemas [英] Need understanding of spring.handlers and spring.schemas

查看:372
本文介绍了需要了解spring.handlers和spring.schemas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题已经通过

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:

  1. spring.handlers spring.schemas 的目的是什么?
  1. What is the purpose of spring.handlers and spring.schemas?

据我了解,这是一种告诉Spring Framework在哪里定位xsd的方法,以便正确连接和加载所有内容.但是...

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...

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

  1. Under what circumstances should I have those two files under the META-INF folder?

在上面链接的另一个问题中,有人知道我为什么必须添加maven-shade-plugin才能在META-INF下创建这两个文件(基于我的所有依赖关系)吗?换句话说,是什么原因导致我不得不使用Maven Shade插件?

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?

推荐答案

spring.handlers和spring.schemas的目的是什么?

What is the purpose of spring.handlers and spring.schemas?

您大概或多或少地发现了它,让我们添加更多详细信息:

well you more or less found it out by yourself, let's add some more details:

某些spring库包含 spring.schemas和一个META-INF目录中的spring.handlers文件

some spring libraries contain a spring.schemas and a spring.handlers file inside a META-INF directory

META-INF/spring.schemas

  • 将(*)模式位置重新映射到库中的xsd
  • (摘要)此库仅支持重新映射的版本

META-INF/spring.handlers

  • 为特定名称空间提供名称空间处理程序类
  • 名称空间处理程序类提供了解析器逻辑来解析spring-batch bean,例如 job 步骤
  • provides namespace handler classes for specific namespaces
  • the namespace handler class provides the parser logic to parse spring-batch beans, like job, step, etc.

(*)实际的重新映射发生在spring应用程序上下文的构建过程中

(*) the actual re-mapping happens during the build of the spring application context

在什么情况下,我应该在 META-INF文件夹?

Under what circumstances should I have those two files under the META-INF folder?

通常,这些文件位于您使用的spring库jar中,但是您可以使用该机制来实现自己的名称空间Bean解析,那么您将拥有自己的文件

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

在上面链接的其他问题中,有人知道我为什么要添加 maven-shade-plugin创建这两个文件(基于我所有的 依赖项)在META-INF下?换句话说,根本原因是什么 那让我不得不使用Maven Shade插件?

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?

如果在spring配置中使用spring名称空间,则需要适当的文件

if you use a spring namespace in your spring configuration, you need the appropriate files

当您要运行Java应用程序时出现问题:

the problem arises when you want to run a java application:

  • 有一个主要班级
    • spring库需要位于类路径上
    • 或全部合并到一个jar中,该jar必须在类路径(*)上
    • with a main class either
      • the spring libraries need to be on the classpath
      • or all is merged into one jar, which has to be on the classpath (*)

      我想您也没有从完整的类路径开始主类,并且我也针对第一个问题更新了 answer

      i guess you did not start the mainclass with the complete classpath and i updated my answer for your first question too

      (*)如果将全部合并到一个jar中,则必须确保将所有spring.schemas/spring.handlers文件的内容合并到一个spring.schemas和一个spring.handlers文件中,请参见回答使用以下配置maven创建一个all-in-one.jar

      (*) 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

      这篇关于需要了解spring.handlers和spring.schemas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆