Intellij Idea 找不到taskdef类com.sun.tools.xjc.XJCTask

kqqjbcuj  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(181)

我试图从一个带有多个模块的Springboot项目中的XSD文件生成类。我试着按照指南给出here.我有下面的配置在我的根构建。gradle

buildscript {
    ext {
        springBootVersion = '1.3.5.RELEASE'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/libs-release" }
        maven { url "https://mvnrepository.com/artifact" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
        //####################### XJC - JDK 1.7/1.8 ####################
        classpath 'com.github.jacobono:gradle-jaxb-plugin:1.3.5'
    }
}

subprojects {

    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'idea'
    apply plugin: 'spring-boot'
    apply plugin: 'io.spring.dependency-management'
    //####################### XJC - JDK 1.7/1.8 ####################
    apply plugin: 'com.github.jacobono.jaxb'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/libs-release" }
        maven { url "https://mvnrepository.com/artifact" }
    }

    task wrapper(type: Wrapper) {
        gradleVersion = '2.3'
    }

}

在我的模块的build.gradle中的config下面

dependencies {
    compile project(':appCommon')
    compile("org.springframework.boot:spring-boot-starter")
}

//####################### XJC - JDK 1.7/1.8 ####################
jaxb {
    xjc {
        xsdDir = "schemas/v1.1"
        generatePackage = "com.test.domain.v1_1"
    }
}

当我在我的模块上从我的IntelliJ运行xjc任务时,我得到一个如下的异常

taskdef class com.sun.tools.xjc.XJCTask cannot be found
 using the classloader AntClassLoader[]

任何帮助什么是出了问题是赞赏

uttx8gqw

uttx8gqw1#

看起来你错过了jaxb依赖项。在模块的build.gradle中添加以下内容:

dependencies { 
  jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41'
  jaxb 'com.sun.xml.bind:jaxb-impl:2.2.7-b41'
  jaxb 'javax.xml.bind:jaxb-api:2.2.7'
}

相关问题