赞
踩
Maven项目 引入依赖即可。
- <!-- https://mvnrepository.com/artifact/xml-apis/xml-apis -->
- <dependency>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- <version>1.4.01</version>
- </dependency>
Gradle在引入"xml-apis:xml-apis:1.4.01"依赖时,始终无法正常引入,需引入解决策略
- configurations.all {
- resolutionStrategy {
- force 'xml-apis:xml-apis:1.4.01'
- }
- }
我本人使用gradle构建项目,引入如下
- configurations {
- compile.exclude group: "ch.qos.logback"
- compile.exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
- compile.exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat"
- compile.exclude group: "org.apache.tomcat", module: "tomcat-jdbc"
- compile.exclude group: "com.zaxxer", module: "HikariCP-java7"
- all {
- resolutionStrategy {
- force 'xml-apis:xml-apis:1.4.01'
- }
- }
- }
贴出报错图
- Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
- at java.lang.ClassLoader.defineClass1(Native Method)
- at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
- at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
- at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
- at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
- at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
- at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
- at java.security.AccessController.doPrivileged(Native Method)
- at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
- at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
- at org.apache.xerces.parsers.AbstractDOMParser.startDocument(Unknown Source)
- at org.apache.xerces.xinclude.XIncludeHandler.startDocument(Unknown Source)
- at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown Source)
- at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown Source)
- at org.apache.xerces.impl.XMLVersionDetector.startDocumentParsing(Unknown Source)
- at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
- at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
- at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
- at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
- at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
- at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:95)
- at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
- at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:454)
- at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:386)
- at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261)
- at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616)
- at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637)
- at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
- at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
- at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
- at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
- at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
- at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
- at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
- at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
- at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
- at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
- at us.codecraft.webmagic.scheduler.DuplicateRemovedScheduler.<init>(DuplicateRemovedScheduler.java:19)
- at us.codecraft.webmagic.scheduler.QueueScheduler.<init>(QueueScheduler.java:19)
- at us.codecraft.webmagic.Spider.<init>(Spider.java:75)
- at us.codecraft.webmagic.Spider.create(Spider.java:119)
- at com.amazon.common.utils.spider.AmanzonPageProcessor.main(AmanzonPageProcessor.java:43)
- Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
- at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
- at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
- ... 44 more
如果对你有帮助 ,欢迎点赞评论哦
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。