美文网首页我爱编程
jaxb2(1.x)和selenium不兼容

jaxb2(1.x)和selenium不兼容

作者: Williamzzl | 来源:发表于2016-09-21 11:12 被阅读0次

jaxb2用来将schema转换为java代码,selenium是GUI自动化测试的lib。由于项目中需要同时支持这两个feature,所以一同配置在pom中:

<dependencies>​ 
  <dependency> 
    <groupId>org.seleniumhq.selenium</groupId>  
    <artifactId>selenium-java</artifactId>  
    <version>2.48.2</version> 
  </dependency> 
</dependencies>
<build> 
  <plugins> 
    <plugin> 
      <groupId>org.codehaus.mojo</groupId>  
      <artifactId>jaxb2-maven-plugin</artifactId>  
      <version>1.5</version>
      <executions> 
        <execution> 
          <id>inbound-common-v12-xjc</id>  
          <goals> 
            <goal>xjc</goal> 
          </goals>  
          <configuration> 
            <outputDirectory>target/generated-sources</outputDirectory>  
            <packageName>com.xxx.data.v12.common</packageName>  
            <bindingDirectory>src/main/resources</bindingDirectory>  
            <bindingFiles>bindings.xml</bindingFiles>  
            <schemaDirectory>src/main/resources/xsd/ASP1.2</schemaDirectory>  
            <schemaFiles>Inbound_Common.xsd,Inbound_FailureResponse.xsd, Inbound_OperationalHistory.xsd, Inbound_TotalResponse.xsd</schemaFiles>  
            <extension>true</extension>  
            <staleFile>target/.inboundcommonschema1XjcStaleFlag</staleFile>  
            <clearOutputDir>false</clearOutputDir>  
            <encoding>UTF-8</encoding> 
          </configuration> 
        </execution> 
      </executions> 
    </plugin> 
  </plugins> 
</build>

结果执行mvn clean install时报错:

[ERROR]
Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.5:xjc
(inbound-user-creation-v12-xjc) on project jcat-test-common: DTD factory class
org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl does not extend from
DTDDVFactory. -> [Help 1]

定位:

从报错看,是在执行jaxb时使用了错误的xerce包,由于项目先加入jaxb2,然后是selenium,所以应该是selenium引入的冲突。为了验证想法,使用mvn dependency:tree查看selenium的依赖库:

[INFO] +- org.seleniumhq.selenium:selenium-java:jar:2.46.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.46.0:compile
[INFO] |  |  \- org.seleniumhq.selenium:selenium-remote-driver:jar:2.46.0:compile
[INFO] |  |     +- cglib:cglib-nodep:jar:2.1_3:compile
[INFO] |  |     +- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] |  |     +- org.seleniumhq.selenium:selenium-api:jar:2.46.0:compile
[INFO] |  |     \- com.google.guava:guava:jar:18.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.46.0:compile
[INFO] |  |  \- net.sourceforge.htmlunit:htmlunit:jar:2.17:compile
[INFO] |  |     +- xalan:xalan:jar:2.7.2:compile
[INFO] |  |     |  \- xalan:serializer:jar:2.7.2:compile
[INFO] |  |     +- org.apache.httpcomponents:httpmime:jar:4.4.1:compile
[INFO] |  |     +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.17:compile
[INFO] |  |     +- xerces:xercesImpl:jar:2.11.0:compile

解决:

在jaxb2 plugin中添加dependence:

<plugin>
... 
  <dependencies> 
    <dependency> 
      <groupId>xerces</groupId>  
      <artifactId>xercesImpl</artifactId>  
      <version>2.9.1</version> 
    </dependency>  
    <dependency> 
      <groupId>xalan</groupId>  
      <artifactId>xalan</artifactId>  
      <version>2.7.2</version> 
    </dependency> 
  </dependencies> 
</plugin>

再次执行mvn clean install,搞定!

相关文章

  • jaxb2(1.x)和selenium不兼容

    jaxb2用来将schema转换为java代码,selenium是GUI自动化测试的lib。由于项目中需要同时支持...

  • 用jQuery前你得知道这些

    1.兼容性 jQuery 1.x 兼容 IE6-8jQuery 2.x 不兼容IE6-8,兼容IE9以后jQuer...

  • DOM 库

    jQuery中文文档 jQuery版本 1.x (兼容到IE6) 2.x (不兼容IE8以上,包括IE8) 3.x...

  • jQuery选择器

    一、jQuery 1.x 版本和 2.x 版本有什么区别? jQuery 1.x 版本代码更老一些,兼容ie6,7...

  • jQuery选择器

    jQuery 1.x 版本和 2.x 版本有什么区别? 目前jQuery有三个大版本: 1.x:兼容ie678,使...

  • jQuery学习:初识

    基础 jQuery就是一个js库 分类: 1.x版本: 能够兼容IE678浏览器 2.x版本:不兼容IE678浏览...

  • [MJSONWP] Bad parameters: BadPar

    selenium兼容问题 解决方式:降级selenium pip uninstall seleniumpip in...

  • 兼容 Spring Boot 1.x 和 2.x 配置类参数绑定

    为了让我提供的通用 Mapper 的 boot-starter 同时兼容 Spring Boot 1.x 和 2....

  • OpenGL ES案例一:平面三角形绘制

    说明:Android中1.x已经过时了,且2.0并不兼容1.x。本文以2.0版本为准! 1. 创建GLSurfac...

  • jquery

    22、JQ的基础语法、核心原理和项目实战 jQ的版本和下载 jQuery版本 1.x:兼容IE6-8,是目前PC端...

网友评论

    本文标题:jaxb2(1.x)和selenium不兼容

    本文链接:https://www.haomeiwen.com/subject/jxhaettx.html