xml是:

  1. <beans xmlns="http://www.springframework.org/schema/beans"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
  3. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  4. http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
  5.  
  6. <dubbo:application name="platform_system_provider" owner="platform_system_provider" organization="llk" logger="slf4j" />
  7.  
  8.   ...

java

  1. package com.example.test_dubbo;
  2.  
  3. import org.apache.commons.collections.map.MultiValueMap;
  4. import org.springframework.beans.MutablePropertyValues;
  5. import org.springframework.beans.PropertyValue;
  6. import org.springframework.beans.factory.config.BeanDefinition;
  7. import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
  8. import org.springframework.beans.factory.xml.XmlBeanFactory;
  9. import org.springframework.context.support.ClassPathXmlApplicationContext;
  10. import org.springframework.core.io.FileSystemResource;
  11.  
  12. import java.util.*;
  13.  
  14. public class DubboXmlDetectorL {
  15.  
  16. public static void main(String[] args) {
  17.  
  18. String dubboXML = "E:\\dev\\erdp2\\erdp_system\\erdp_system_app\\src\\main\\resources\\dubbo.xml";
  19. String dubboXML2 = "E:\\dev\\ppm\\platform_system\\02_Src\\platform_system\\platform_system_provider\\src\\main\\resources\\dubbo-provider.xml";
  20. compareDubboXml(dubboXML, dubboXML2);
  21. }
  22.  
  23. private static void compareDubboXml(String dubboXML, String dubboXML2) {
  24. System.out.println("left = " + dubboXML);
  25. Set list1 = getDobboXml(dubboXML);
  26. System.out.println("right = " + dubboXML2);
  27. Set list2 = getDobboXml(dubboXML2);
  28.  
  29. System.out.println("left = " + list1);
  30. System.out.println("right = " + list2);
  31.  
  32. Set set2 = new HashSet(list1);
  33. list1.removeAll(list2);
  34. System.out.println("list111 = " + list1);
  35.  
  36. list2.removeAll(set2);
  37. System.out.println("list222 = " + list2);
  38.  
  39. }
  40.  
  41. private static Set getDobboXml(String dubboXML) {
  42. XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(new FileSystemResource(dubboXML));
  43. String[] beanDefinitionNames = xmlBeanFactory.getBeanDefinitionNames();
  44.  
  45. MultiValueMap multiValueMap = new MultiValueMap();
  46. for (int i = ; i < beanDefinitionNames.length; i++) {
  47. String beanDefinitionName = beanDefinitionNames[i];
  48. BeanDefinition beanDefinition = xmlBeanFactory.getBeanDefinition(beanDefinitionName);
  49. Class<? extends BeanDefinition> aClass = beanDefinition.getClass();
  50.  
  51. Object anInterface = beanDefinition.getAttribute("interface");
  52. // System.out.println("anInterface = " + anInterface);
  53. MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
  54. PropertyValue anInterface1 = propertyValues.getPropertyValue("interface");
  55.  
  56. if (anInterface1 != null) {
  57. String interfaceProp = (String) anInterface1.getValue();
  58. PropertyValue version = propertyValues.getPropertyValue("version");
  59. PropertyValue group = propertyValues.getPropertyValue("group");
  60.  
  61. String key = interfaceProp;//+":"+ (version==null?"":version.getValue())+ ":" + (group==null?"":group.getValue());
  62. if (multiValueMap.containsKey(key)) {
  63.  
  64. }
  65. multiValueMap.put(key, beanDefinitionName);
  66. }
  67.  
  68. }
  69.  
  70. Set set = multiValueMap.entrySet();
  71. for (Iterator iterator = set.iterator(); iterator.hasNext(); ) {
  72. Object entry = iterator.next();
  73. if (entry instanceof Map.Entry) {
  74. ArrayList value = (ArrayList) ((Map.Entry) entry).getValue();
  75. if (value.size() > ) {
  76. System.out.println(" = " + entry );
  77. }
  78. }
  79. }
  80.  
  81. return multiValueMap.keySet();
  82. }
  83.  
  84. private static void test1() {
  85. String xmls = "E:\\dev\\erdp2\\erdp_discuss\\erdp_discuss_app\\src\\main\\resources\\dubbo.xml\n" +
  86. "E:\\dev\\erdp2\\erdp_doc\\erdp_doc_app\\src\\main\\resources\\dubbo.xml\n" +
  87. "E:\\dev\\erdp2\\erdp_project\\erdp_project_app\\src\\main\\resources\\dubbo.xml\n" +
  88. "E:\\dev\\erdp2\\erdp_scheduler\\erdp_scheduler_app\\src\\main\\resources\\dubbo.xml\n" +
  89. "E:\\dev\\erdp2\\erdp_system\\erdp_system_app\\src\\main\\resources\\dubbo.xml\n" +
  90. "E:\\dev\\erdp2\\erdp_workflow\\erdp_workflow_app\\src\\main\\resources\\dubbo.xml";
  91. String[] split = xmls.split("\n");
  92. for (int i = ; i < split.length; i++) {
  93. String s = split[i];
  94. System.out.println("XML = " + s);
  95. detectDobboXml(s);
  96. }
  97.  
  98. String dubboXML = "E:\\dev\\erdp2\\erdp_doc\\erdp_doc_app\\src\\main\\resources\\dubbo.xml";
  99. dubboXML = "dubbo.xml";
  100. dubboXML = "E:\\dev\\erdp2\\test_nacos\\src\\test\\java\\dubbo.xml";
  101. // detectDobboXml(dubboXML);
  102. }
  103.  
  104. private static void detectDobboXml(String dubboXML) {
  105. XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(new FileSystemResource(dubboXML));
  106. String[] beanDefinitionNames = xmlBeanFactory.getBeanDefinitionNames();
  107.  
  108. // DefaultListableBeanFactory bdr = new DefaultListableBeanFactory();
  109. // bdr.set
  110. // XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(bdr);
  111. // NamespaceHandlerResolver namespaceHandlerResolver = xmlBeanDefinitionReader.getNamespaceHandlerResolver();
  112. // System.out.println("namespaceHandlerResolver = " + namespaceHandlerResolver);
  113. // NamespaceHandlerResolver nsr = new DefaultNamespaceHandlerResolver();
  114. // xmlBeanDefinitionReader.setNamespaceHandlerResolver(nsr);
  115.  
  116. MultiValueMap multiValueMap = new MultiValueMap();
  117. for (int i = ; i < beanDefinitionNames.length; i++) {
  118. String beanDefinitionName = beanDefinitionNames[i];
  119. // System.out.println("beanDefinitionName = " + beanDefinitionName);
  120. BeanDefinition beanDefinition = xmlBeanFactory.getBeanDefinition(beanDefinitionName);
  121. // System.out.println("beanDefinition = " + beanDefinition);
  122. Class<? extends BeanDefinition> aClass = beanDefinition.getClass();
  123.  
  124. Object anInterface = beanDefinition.getAttribute("interface");
  125. // System.out.println("anInterface = " + anInterface);
  126. MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
  127. PropertyValue anInterface1 = propertyValues.getPropertyValue("interface");
  128. // System.out.println("anInterface1 = " + anInterface1);
  129. // propertyValues.getPropertyValueList();
  130.  
  131. if (anInterface1 != null) {
  132. String interfaceProp = (String) anInterface1.getValue();
  133. PropertyValue version = propertyValues.getPropertyValue("version");
  134. PropertyValue group = propertyValues.getPropertyValue("group");
  135.  
  136. String key = interfaceProp+":"+ (version==null?"":version.getValue())+ ":" + (group==null?"":group.getValue());
  137. // System.out.println("aClass = " + aClass);
  138. if (multiValueMap.containsKey(key)) {
  139. // multiValueMap.put(interfaceProp, beanDefinitionName);
  140. // System.out.println("beanDefinitionName = " + beanDefinitionName + " interface = " + interfaceProp);
  141. // System.out.println(" interface = " + interfaceProp + " beanDefinitionNames = " + multiValueMap.get(interfaceProp));
  142. }
  143. multiValueMap.put(key, beanDefinitionName);
  144. // multiValueMap.put(interfaceProp, aClass);
  145. }
  146.  
  147. }
  148.  
  149. // Object dubbo = xmlBeanFactory.getBean("dubbo");
  150. // System.out.println("dubbo = " + dubbo);
  151. // BeanDefinition dubbo1 = xmlBeanFactory.getBeanDefinition("dubbo");
  152. // System.out.println("dubbo1 = " + dubbo1.getClass());
  153.  
  154. Set set = multiValueMap.entrySet();
  155. for (Iterator iterator = set.iterator(); iterator.hasNext(); ) {
  156. Object entry = iterator.next();
  157. // System.out.println("entry = " + entry + " v " + multiValueMap.get(entry));
  158. if (entry instanceof Map.Entry) {
  159. ArrayList value = (ArrayList) ((Map.Entry) entry).getValue();
  160. // System.out.println("value = " + value.size());
  161. if (value.size() > ) {
  162. System.out.println(" = " + entry );
  163. }
  164. }
  165. // Collection collection = multiValueMap.getCollection(entry);
  166. // if (collection != null && collection.size() > 1) {
  167. // System.out.println("key = " + entry);
  168. // dumpCollection(collection);
  169. // }
  170. }
  171.  
  172. // Collection values = multiValueMap.values();
  173. // System.out.println("values = " + values);
  174. }
  175.  
  176. private static void dumpCollection(Collection values) {
  177. for (Iterator iterator = values.iterator(); iterator.hasNext(); ) {
  178. Object next = iterator.next();
  179. System.out.println("next = " + next);
  180. }
  181. }
  182.  
  183. private static void test() {
  184. String dubboXML = "E:\\dev\\erdp2\\erdp_doc\\erdp_doc_app\\src\\main\\resources\\dubbo.xml";
  185. dubboXML = "dubbo.xml";
  186. ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
  187. new String[]{dubboXML});
  188. context.start();
  189.  
  190. ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
  191. String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
  192. for (int i = ; i < beanDefinitionNames.length; i++) {
  193. String beanDefinitionName = beanDefinitionNames[i];
  194. System.out.println("beanDefinitionName = " + beanDefinitionName);
  195. }
  196. }
  197. }

出现错误:dubbo  通配符的匹配很全面, 但无法找到元素 'dubbo:service' 的声明。

  1. ::44.125 [main] WARN o.s.b.f.xml.XmlBeanDefinitionReader - Ignored XML validation warning
  2. org.xml.sax.SAXParseException: schema_reference.: 无法读取方案文档 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', 原因为 ) 无法找到文档; ) 无法读取文档; ) 文档的根元素不是 <xsd:schema>。
  3. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:)
  4. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:)
  5. at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:)
  6. at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:)
  7. at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:)
  8. at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaWarning(XSDHandler.java:)
  9. at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument1(XSDHandler.java:)
  10. at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:)
  11. at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:)
  12. at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:)
  13. at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:)
  14. at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:)
  15. at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:)
  16. at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:)
  17. at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:)
  18. at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:)
  19. at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:)
  20. at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:)
  21. at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:)
  22. at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:)
  23. at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:)
  24. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:)
  25. at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:)
  26. at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:)
  27. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:)
  28. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:)
  29. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:)
  30. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:)
  31. at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:)
  32. at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:)
  33. at com.example.test_nacos.DetectorL.detectDobboXml(DetectorL.java:)
  34. at com.example.test_nacos.DetectorL.main(DetectorL.java:)
  35. Caused by: java.net.ConnectException: Connection timed out: connect
  36. at java.net.DualStackPlainSocketImpl.connect0(Native Method)
  37. at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:)
  38. at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:)
  39. at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:)
  40. at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:)
  41. at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:)
  42. at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:)
  43. at java.net.Socket.connect(Socket.java:)
  44. at java.net.Socket.connect(Socket.java:)
  45. at sun.net.NetworkClient.doConnect(NetworkClient.java:)
  46. at sun.net.www.http.HttpClient.openServer(HttpClient.java:)
  47. at sun.net.www.http.HttpClient.openServer(HttpClient.java:)
  48. at sun.net.www.http.HttpClient.<init>(HttpClient.java:)
  49. at sun.net.www.http.HttpClient.New(HttpClient.java:)
  50. at sun.net.www.http.HttpClient.New(HttpClient.java:)
  51. at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:)
  52. at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:)
  53. at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:)
  54. at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:)
  55. at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:)
  56. at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:)
  57. at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:)
  58. at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:)
  59. at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:)
  60. at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:)
  61. at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.parse(SchemaDOMParser.java:)
  62. at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:)
  63. ... common frames omitted
  64. Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line in XML document from file [E:\dev\erdp2\erdp_discuss\erdp_discuss_app\src\main\resources\dubbo.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: ; columnNumber: ; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'dubbo:application' 的声明。
  65. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:)
  66. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:)
  67. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:)
  68. at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:)
  69. at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:)
  70. at com.example.test_nacos.DetectorL.detectDobboXml(DetectorL.java:)
  71. at com.example.test_nacos.DetectorL.main(DetectorL.java:)
  72. Caused by: org.xml.sax.SAXParseException; lineNumber: ; columnNumber: ; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'dubbo:application' 的声明。
  73. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:)
  74. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:)
  75. at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:)
  76. at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:)
  77. at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:)
  78. at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:)
  79. at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:)
  80. at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:)
  81. at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:)
  82. at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:)
  83. at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:)
  84. at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:)
  85. at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:)
  86. at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:)
  87. at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:)
  88. at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:)
  89. at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:)
  90. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:)
  91. at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:)
  92. at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:)
  93. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:)
  94. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:)
  95. ... more

启动过程中,感觉会去下载,但是下载了好一会却下载不成功。。

其实 Spring提供了一种机制,默认从本地加载XSD文件 。仔细检查,好像命名空间有问题, 是dubbo从2.6.5升级到 2.7.1 引起的吗? code.alibabatech.com 改成 dubbo.apache.org ,还是不行:

Unable to locate Spring NamespaceHandler for XML schema namespace [http://dubbo.apache.org/schema/dubbo]

  1. Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://dubbo.apache.org/schema/dubbo]
  2. Offending resource: file [E:\dev\erdp2\erdp_system\erdp_system_app\src\main\resources\dubbo.xml]
  3.  
  4. at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:)
  5. at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:)
  6. at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:)
  7. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:)
  8. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:)
  9. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:)
  10. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:)
  11. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:)
  12. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:)
  13. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:)
  14. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:)
  15. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:)
  16. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:)
  17. at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:)
  18. at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:)
  19. at com.example.test_nacos.DetectorL.getDobboXml(DetectorL.java:)
  20. at com.example.test_nacos.DetectorL.compareDubboXml(DetectorL.java:)
  21. at com.example.test_nacos.DetectorL.main(DetectorL.java:)

想起来了之前读spring源码的时候, 对应于每一个xml 的命名空间,spring 都需要一个NamespaceHandler,比如Context需要  ContextNamespaceHandler  。
难道要修改jar 的spring.handlers/spring.schemas 文件? 检查 spring-context-5.1.5.RELEASE\META-INF\spring.handlers ,发现基本正常

http\://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler
http\://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler
http\://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler
http\://www.springframework.org/schema/task=org.springframework.scheduling.config.TaskNamespaceHandler
http\://www.springframework.org/schema/cache=org.springframework.cache.config.CacheNamespaceHandler

突然想到,dubbo-jar 都没有引入呢!

  1. <dependency>
  2. <groupId>org.apache.dubbo</groupId>
  3. <artifactId>dubbo</artifactId>
  4. <version>2.7.</version>
  5. </dependency>

加入就好了!

------------------------------------------------------------------------------------------------------------------------------------------------
总结一下

这样的问题,通常是由于升级引起的,特别是有些jar升级后不兼容之前的版本就会出现。
但Spring很贴心,把旧版本的XSD文件也全放了。这样可以防止升级了Spring版本,而配置文件里用的还是旧版本的XSD文件,然后断网了,应用启动不了。

我解压dubbo jar之后看到spring-context-5.1.5.RELEASE\META-INF\spring.schemas :

可见,基本上都有了。但是xsd 只有一个:

所以,如果用最新的jar ,然后xml配置老的 命名空间,那么还是会去下载xsd。下载

参考
https://dslztx.github.io/blog/2019/02/20/Unable-to-locate-Spring-NamespaceHandler-for-XML-schema-namespace/
https://www.jianshu.com/p/b16a4384dfdb
https://blog.csdn.net/wcf2010/article/details/86229222
https://blog.csdn.net/wxydaisy/article/details/40650405

DUBBO: xml文件无法解析的更多相关文章

  1. JDOM方法实现对XML文件的解析

    首先要下载JDOM.jar包,下载地址:http://download.csdn.net/detail/ww6055/8880371 下载到JDOM.jar包之后导入到工程中去. 实例程序: book ...

  2. xml文件的解析

    1. xml文件的解析 void CDataMgr::readStringData() { std::string xml_name = "config/string.xml"; ...

  3. [置顶] Android开发之XML文件的解析

    Android系统开发之XML文件的解析 我们知道Http在网络传输中的数据组织方式有三种分别为:XML方式.HTML方式.JSON方式.其中XML为可扩展标记语言,如下: <?xml vers ...

  4. 类的反射及xml文件的解析

    类的反射 xml文件的解析 .properties||.xml配置文件的创建及读取内容 //创建对象 Properties properties = new Properties(); //存储 pr ...

  5. JAVA读取XML文件并解析获取元素、属性值、子元素信息

    JAVA读取XML文件并解析获取元素.属性值.子元素信息 关键字 XML读取  InputStream   DocumentBuilderFactory   Element     Node 前言 最 ...

  6. 用SAX和PULL进行XML文件的解析与生成

    XML解析有传统的dom方法还有Jsoup,SAX,PULL等,这里讲的是比较省内存的SAX和PULL方法.Android中极力推荐用PULL的方式来解析,我个人觉得pull确实比较简单,但其内部的逻 ...

  7. 【文件处理】xml 文件 DOM解析

    一.Java解析xml.解析xml四种方法.DOM.SAX.JDOM.DOM4j.XPath 此文针对其中的DOM方法具体展开介绍及代码分析 sax.dom是两种对xml文档进行解析的方法(没有具体实 ...

  8. Java中使用DOM4J来生成xml文件和解析xml文件

    一.前言 现在有不少需求,是需要我们解析xml文件中的数据,然后导入到数据库中,当然解析xml文件也有好多种方法,小编觉得还是DOM4J用的最多最广泛也最好理解的吧.小编也是最近需求里遇到了,就来整理 ...

  9. 用java操作XML文件(DOM解析方式)

    XML 可扩展标记语言(Extensible Markup Language),是独立于软件和硬件的传输工具. XML的作用: (1)用作配置文件 (2)简化数据共享 (3)简化数据传输 XML DO ...

随机推荐

  1. yarn和npm的对比以及yarn的使用

    0--前言 为什么要使用yarn,如果你从事前端开发有些年头了,那你肯定对npm又爱又恨,爱就不说了,恨嘛,就是NPM经常奇慢和卡顿,这还能忍,经常各种错误就没法忍了,尤其是他人创建的项目,自己在安装 ...

  2. IIS+PHP上传文件大小限制和上传时间限制,iis7和iis8上传文件大小限制和上传时间限制

    先说IIS这边的配置                                                                  一:点击站点“管理”下的“配置编辑器”. 二:设 ...

  3. 第三章 学习Shader所需的数学基础(2)

    目录 1.坐标空间 1.2 坐标空间的变换 @ 1.坐标空间 我们在以前渲染流水线中就接触了坐标空间的变换.例如,在学习顶点着色器流水线阶段时,我们说过,顶点着色器的最基本功能就是把模型的顶点坐标从模 ...

  4. Python如何爬取实时变化的WebSocket数据【华为云技术分享】

    一.前言 作为一名爬虫工程师,在工作中常常会遇到爬取实时数据的需求,比如体育赛事实时数据.股市实时数据或币圈实时变化的数据.如下图: Web 领域中,用于实现数据'实时'更新的手段有轮询和 WebSo ...

  5. 【nodejs原理&源码赏析(7)】【译】Node.js中的事件循环,定时器和process.nextTick

    目录 Event Loop 是什么? Event Loop 基本解释 事件循环阶段概览 事件循环细节 timers pending callbacks poll阶段 check close callb ...

  6. eNSP 简介及基础操作

    eNSP 一. eNSP简介 eNSP是一款由华为自主研发的.免费的.可扩展的.图形化操作的网络仿真工具平台,主要对企业网络路由器.交换机及相关物理设备进行软件仿真,支持大型网络模拟.界面如下: 界面 ...

  7. 一道时间复杂度为O(N)空间复杂度为O(1)的排序问题

    题目:对1, 2, ... , n的一个无序数组,排序,要求时间复杂度为O(N),空间复杂度为O(1). 思路:该题利用数组元素和数组下标相差1的关系,Java代码如下: import java.ut ...

  8. Python3 常用的几个内置方法

    目录 max()/min() filter() 过滤 map() 映射 sorted筛选 reduce()减少 max()/min() 传入一个参数 (可迭代对象), 返回这个可迭代对象中最大的元素 ...

  9. RNN循环神经网络

    1.为什么还会有RNN? CNN(卷积神经网络)我们会发现, 他们的输出都是只考虑前一个输入的影响而不考虑其它时刻输入的影响, 比如简单的猫,狗,手写数字等单个物体的识别具有较好的效果. 但是, 对于 ...

  10. 【Eureka】服务发现调用

    [Eureka]服务发现调用 转载:https://www.cnblogs.com/yangchongxing/p/10779832.html 1.使用 Netfix Feign 客户端调用服务 首先 ...