spring xsd 加载问题

 

首先spring的xml配置,在文章头部会有http://www.springframework.org/schema/beans/spring-beans.xsd 
类似于这种地址。 
加载顺序为: 
1.首先在jar包中找,在jar中有个META-INF文件夹,其中有文件为spring.handlers·spring.schemas 
文件中会将uri的xsd文件的地址进行指定。

http\://code.alibabatech.com/schema/dubbo/dubbo.xsd=META-INF/dubbo.xsd
1
所以在本地可以找到 
2.如果没有的话,去访问将文件进行下载。 
以上是加载的逻辑。 
说一下个人出现的问题,在写项目的时候,发现找不到了dubbo.xsd,而且dubbo.xsd的uri已经停了,只能在本地找, 
使用maven打包,发现xsd文件都在却还是找不到,发现之前打出来的包中的spring.schemas中没有dubbo.xsd的配置 
后来在google后发现是maven-assembly-plugin在打包的时候只能将一个版本的配置打到spring.schemas中,导致缺少 
配置。 
最后使用shade插件,打包时在对spring.schemas文件处理上,它能够将所有jar里的spring.schemas文件进行合并, 
具体配置为:


  org.apache.maven.plugins
  maven-shade-plugin
  2.4.3
 
   
      package
     
        shade
     

     
       
         
            META-INF/spring.handlers
         

         
            META-INF/spring.schemas
         

          /**下面是具体的主类**/
         
            com.xxx.MainClass
         

       

     

   

 



然后使用mvn clean install命令进行打包 
一共会生成两个包,一个源码包是original开头的,另一是有依赖的包。


--------------------- 
原文:https://blog.csdn.net/qq_21909689/article/details/82594365 
 

你可能感兴趣的:(spring全家桶)