Deorg.apache.xerces.parsers.XIncludeAwareParserConfiguration无法强制转换为org.apache.xerces.xni.parser.XMLParserConfiguration

问题描述 投票:0回答:1

我在gradle项目中使用了Xerces jar,然后在gradle插件中使用了这个项目的jar:事实上,我正在开发一个gradle插件,其中包含使用gradle项目jar的一些函数的自定义任务;当我尝试运行任务时,我有这个错误;但是,当我尝试从gradle项目运行该函数时,它可以正常工作。当我尝试在网上搜索时,我发现错误的原因是JRE打包了Xerces的一个版本,但我不知道如何解决问题...

我的gradle项目的依赖项块:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"      
    }
}

 dependencies {

testImplementation 'junit:junit:4.12'
testImplementation group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
implementation (group: 'commons-logging', name: 'commons-logging', version: '1.2')
implementation(group: 'log4j', name: 'log4j', version: '1.2.17')
implementation (group: 'javax', name: 'javaee-api', version: '8.0') 
implementation group: 'org.hibernate', name: 'hibernate-core', version: '5.2.17.Final'
implementation (group: 'commons-io', name: 'commons-io', version: '2.6')
implementation(group: 'org.apache.ant', name: 'ant', version: '1.10.3')  
implementation( group: 'xerces', name: 'xercesImpl', version: '2.11.0')
implementation (group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3')
implementation( group: 'net.sf.jt400', name: 'jt400', version: '9.5') 
implementation(group: 'mysql', name: 'mysql-connector-java', version: '5.0.4') 
implementation (group: 'org.apache.derby', name: 'derbyclient', version: '10.14.2.0')
implementation group: 'com.oracle', name: 'ojdbc6', version: '11.2.0.3' 


implementation group: 'Ext', name: 'sqljdbc', version: 'sqljdbc'
implementation group: 'toplink.essentials', name: 'toplink-essentials', version: '2.1-60',transitive:false
implementation group: 'org.springframework', name: 'spring', version: '2.5.6' 
implementation group: 'org.swinglabs', name: 'swing-layout', version: '1.0.3'
implementation group: 'xalan', name: 'xalan', version: '2.7.2'
implementation group: 'com.github.javaparser', name: 'javaparser-core', version: '3.6.6'
implementation group: 'org.gradle', name: 'gradle-tooling-api', version: '4.3'
implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
implementation group: 'org.hibernate', name: 'hibernate-cglib-repack', version: '2.1_3'

implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'

implementation group: 'xml-apis', name: 'xml-apis', version: '1.4.01'
implementation (group: 'xalan', name: 'serializer', version: '2.7.2')
implementation(group:'org.apache.ant', name: 'ant-launcher', version: '1.10.3')

}

这是我的gradle插件的Build.gradle:

group = 'CustomPlugin'
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
archivesBaseName ='CustomPluginGradle'
version='10.0.0'
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"      
    }
}

artifactory {
contextUrl = "${artifactory_contextUrl}" 
    publish {
        repository {
            repoKey = 'repo-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
        }
        defaults {
             publishConfigs('archives', 'published')  
             publishBuildInfo = false 
             publishArtifacts = false
             publishPom = true
             publishIvy = false

        }
    }
    resolve {
        repository {
            repoKey = 'repo-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
}

publishing {    
  publications {   
     mavenJava(MavenPublication) { 
         from components.java  
      } 
      CustomPluginGradle(MavenPublication) {
          group='CustomPlugin'
       } 
   }
}
jar {
from ('src/main/java'){
exclude '**/**.java'}
}


repositories {
    jcenter()
}

dependencies {
    compile gradleApi()
    testImplementation 'junit:junit:4.12'
    testImplementation group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
    implementation (group: 'commons-logging', name: 'commons-logging', version: '1.2')
    implementation(group: 'log4j', name: 'log4j', version: '1.2.17')
    implementation (group: 'javax', name: 'javaee-api', version: '8.0') 
    implementation group: 'org.hibernate', name: 'hibernate-core', version: '5.2.17.Final'
    implementation (group: 'commons-io', name: 'commons-io', version: '2.6')
    implementation(group: 'org.apache.ant', name: 'ant', version: '1.10.3')  
    implementation( group: 'xerces', name: 'xercesImpl', version: '2.11.0')
    implementation (group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3')
    implementation( group: 'net.sf.jt400', name: 'jt400', version: '9.5') 
    implementation(group: 'mysql', name: 'mysql-connector-java', version: '5.0.4') 
    implementation (group: 'org.apache.derby', name: 'derbyclient', version: '10.14.2.0')
    implementation group: 'com.oracle', name: 'ojdbc6', version: '11.2.0.3' 

    implementation group: 'Ext', name: 'sqljdbc', version: 'sqljdbc'
    implementation group: 'toplink.essentials', name: 'toplink-essentials', version: '2.1-60',transitive:false
    implementation group: 'org.springframework', name: 'spring', version: '2.5.6' 
    implementation group: 'org.swinglabs', name: 'swing-layout', version: '1.0.3'
    implementation group: 'xalan', name: 'xalan', version: '2.7.2'
    implementation group: 'com.github.javaparser', name: 'javaparser-core', version: '3.6.6'
    implementation group: 'org.gradle', name: 'gradle-tooling-api', version: '4.3'
    implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'
    implementation group: 'org.hibernate', name: 'hibernate-cglib-repack', version: '2.1_3'

    implementation group: 'xml-apis', name: 'xml-apis', version: '1.4.01'
    implementation (group: 'xalan', name: 'serializer', version: '2.7.2')
    implementation(group:'org.apache.ant', name: 'ant-launcher', version: '1.10.3')
}

configurations.all {
    transitive = false
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
java gradle plugins xerces
1个回答
0
投票

这是你的Xerces 2.11.0版本和通过传递依赖带来的版本之间的冲突。试试这个 :

configurations.all {
    resolutionStrategy {
        force 'xerces:xercesImpl:2.11.0'
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.