gpt4 book ai didi

java - Gradle 构建失败

转载 作者:行者123 更新时间:2023-12-03 19:05:10 28 4
gpt4 key购买 nike

我正在使用 https://spring.io/guides/gs/producing-web-service/#initial 上的教程来尝试生成 SOAP Web 服务。我正在使用 Gradle 来管理我的依赖项。

我有一个 .xsd 文件,它指定了我希望 gradle 创建的某些类。

但是,当我尝试在 eclipse 中的 build.gradle 文件上运行 gradle 构建时,出现以下错误:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\zekucukkose\workspace2\gs-producing-web-service-initial\build.gradle'
line: 32

* What went wrong:
A problem occurred evaluating root project 'gs-producing-web-service-initial'.

> Could not find method jaxb() for arguments [com.sun.xml.bind:jaxb-xjc:2.2.4-1]
on root project 'gs-producing-web-service-initial'.

第 27 至 34 行如下:
27 dependencies {
28 compile("org.springframework.boot:spring-boot-starter-web")
29 compile("org.springframework.boot:spring-boot-starter-ws")
30 testCompile("org.springframework.boot:spring-boot-starter-test")
31 compile("wsdl4j:wsdl4j:1.6.1")
32 jaxb("com.sun.xml.bind:jaxb-xjc:2.2.4-1")
33 compile(files(genJaxb.classesDir).builtBy(genJaxb))
34 }

据我所知,jaxb 是用来生成实际类的。

如果有人可以提供帮助,我将不胜感激。
谢谢

这是整个脚本:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.7.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
baseName = 'gs-producing-web-service'
version = '0.1.0'
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-ws")
testCompile("org.springframework.boot:spring-boot-starter-test")
compile("wsdl4j:wsdl4j:1.6.1")
jaxb("com.sun.xml.bind:jaxb-xjc:2.2.4-1")
compile(files(genJaxb.classesDir).builtBy(genJaxb))
}

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

task genJaxb {
ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
ext.classesDir = "${buildDir}/classes/jaxb"
ext.schema = "src/main/resources/countries.xsd"

outputs.dir classesDir

doLast() {
project.ant {
taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
classpath: configurations.jaxb.asPath
mkdir(dir: sourcesDir)
mkdir(dir: classesDir)

xjc(destdir: sourcesDir, schema: schema) {
arg(value: "-wsdl")
produces(dir: sourcesDir, includes: "**/*.java")
}

javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true,
debugLevel: "lines,vars,source",
classpath: configurations.jaxb.asPath) {
src(path: sourcesDir)
include(name: "**/*.java")
include(name: "*.java")
}

copy(todir: classesDir) {
fileset(dir: sourcesDir, erroronmissingdir: false) {
exclude(name: "**/*.java")
}
}
}
}
}

configurations {
jaxb
}

jar {
baseName = 'gs-producing-web-service'
version = '0.1.0'
from genJaxb.classesDir
}

最佳答案

您需要添加 jaxb 作为配置。这条路:

configurations {
jaxb
}

你能提供整个脚本吗?还是项目来源?

关于java - Gradle 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33653090/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com