简体   繁体   English

找不到参数jaxws()的方法[com.sun.xml.ws:jaxws-tools:2.1.4]

[英]Could not find method jaxws() for arguments [com.sun.xml.ws:jaxws-tools:2.1.4]

I am trying to generate java classes using following code but it's failing for some gradle plugin issue. 我正在尝试使用以下代码生成Java类,但由于某些gradle插件问题而失败。

I searched for it and found there are many plugin available for generating the java classed from xsd but only few plugins for generating the code form wsdl . 我搜索了它,发现有许多插件可用于生成从xsd分类的java,但只有少数plugins用于生成代码形式wsdl jaxb is one of them which I thought to use. jaxb是我想使用的其中之一。

Here is my build.gradle file: 这是我的build.gradle文件:

configurations {
    jaxws
}
buildscript {
    ext {
        springBootVersion = "2.1.4.RELEASE"
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
        jaxws 'com.sun.xml.ws:jaxws-tools:2.1.4'
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

repositories {
    mavenCentral()
} 

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-actuator'
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.springframework.boot:spring-boot-starter-web-services'     
    compile 'org.apache.httpcomponents:httpclient'
    compile 'com.sun.xml.ws:jaxws-tools:2.1.4'
} 

task wsimport {
    ext.destDir = file("${projectDir}/src/main/generated")
    doLast {
        ant {
            sourceSets.main.output.classesDir.mkdirs()
            destDir.mkdirs()
            taskdef(name: 'wsimport',
                    classname: 'com.sun.tools.ws.ant.WsImport',
                    classpath: configurations.jaxws.asPath
            )
            wsimport(keep: true,
                    destdir: sourceSets.main.output.classesDir,
                    sourcedestdir: destDir,
                    extension: "true",
                    verbose: "false",
                    quiet: "false",
                    package: "com.abc.test",
                    xnocompile: "true",
                    wsdl: '${projectDir}/src/main/resources/wsdls/wsdl_1.0.0.wsdl') {
                xjcarg(value: "-XautoNameResolution")
            }
        }
    }
}

compileJava {
    dependsOn wsimport
    source wsimport.destDir
}
bootJar {
    baseName = 'API'
    version = '1.0'

}

Now here is the error I am getting when I try to build project using command line. 现在这是我尝试使用命令行构建项目时遇到的错误。

C:\DEV\workspace\API>gradlew clean build --stacktrace

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\DEV\workspace\API\build.gradle' line: 14

* What went wrong:
A problem occurred evaluating root project 'API'.
> Could not find method jaxws() for arguments [com.sun.xml.ws:jaxws-tools:2.1.4] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. 

Taking reference from this code; 引用此代码; https://gist.github.com/ae6rt/8883335 https://gist.github.com/ae6rt/8883335

configurations {
    jaxws
}

buildscript {
    dependencies {
        jaxws 'com.sun.xml.ws:jaxws-tools:2.1.4'
    }
}

The configuration jaxws is not applicable for build script dependencies. 配置jaxws不适用于构建脚本依赖项。 First, it is placed outside of the buildscript configuration and thus not visible. 首先,它被放置在buildscript配置之外,因此不可见。 Second, build script dependencies allow for classpath configuration only ( External dependencies for the build script ). 其次,构建脚本依赖项仅允许classpath配置( 构建脚本的外部依赖项 )。 Removing jaxws 'com.sun.xml.ws:jaxws-tools:2.1.4' from the build script dependencies fixes issue 从构建脚本依赖项中删除jaxws 'com.sun.xml.ws:jaxws-tools:2.1.4'修复了问题

Could not find method jaxws() for arguments [...] 找不到参数jaxws()的方法[...]

Next issue is that you define the jax-ws dependency as 下一个问题是您将jax-ws依赖项定义为

compile 'com.sun.xml.ws:jaxws-tools:2.1.4'

and try to reference it as 并尝试引用为

taskdef(name: 'wsimport',
        classname: 'com.sun.tools.ws.ant.WsImport',
        classpath: configurations.jaxws.asPath)
                                  ^^^^^

The jaxws configuration has no dependencies defined so far, thus the path is empty. 到目前为止, jaxws配置尚未定义依赖项,因此路径为空。 Changing the dependency in question to 将相关依赖项更改为

jaxws 'com.sun.xml.ws:jaxws-tools:2.1.4'

is likely to resolve this issue for you. 可能会为您解决此问题。


Update 更新

Since Gradle replaced File classesDir with FileCollection classesDirs , as per your comment you're now receiving error 由于Gradle用FileCollection classesDirs替换了File classesDir ,根据您的评论,您现在收到错误

No signature of method: org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection.mkdirs() is applicable for argument types: () values: [] Possible solutions: min(), tails(), first(), inits(), minus(org.gradle.api.file.FileCollection), min(java.util.Comparator) 没有方法签名:org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection.mkdirs()适用于参数类型:()值:[]可能的解决方案:min(),tails(),first(),inits (),减号(org.gradle.api.file.FileCollection),减号(java.util.Comparator)

on line 在线

sourceSets.main.output.classesDirs.mkdirs()

If you've got only 1 classes output dir, a workaround would be to use 如果您只有1个类的输出目录,则可以使用一种解决方法

sourceSets.main.output.classesDirs.singleFile.mkdirs()

(from: FileCollection.getSingleFile() ) (来自: FileCollection.getSingleFile()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.sun.xml.ws:jaxws-rt:pom:2.2.10 的 POM 无效 - The POM for com.sun.xml.ws:jaxws-rt:pom:2.2.10 is invalid 无法读取com.sun.xml.ws:jaxws-rt:jar:2.2.8的工件描述符:UnresolvableModelException:无法传输com.sun.xml.ws:bundles:pom - Failed to read artifact descriptor for com.sun.xml.ws:jaxws-rt:jar:2.2.8: UnresolvableModelException: Failure to transfer com.sun.xml.ws:bundles:pom JAXWS-RT:获取 com.sun.xml.ws.spi.db.DatabindingException 绑定一个简单的类 - JAXWS-RT: getting com.sun.xml.ws.spi.db.DatabindingException binding a simple class sun-jaxws.xml 中的 JAX-WS 多个端点 - JAX-WS multiple endpoints in sun-jaxws.xml Wsimport from jaxws-tools:3.0.0 在 ClassNotFoundException 上崩溃 - Wsimport from jaxws-tools:3.0.0 crashes on ClassNotFoundException jaxws-rt.jar中的“ / com / sun / xml / ws /”软件包和rt.jar中的“ / com / sun / xml / internal / ws /”软件包之间有什么区别 - what is the Difference between the “/com/sun/xml/ws/” package in jaxws-rt.jar and “/com/sun/xml/internal/ws/” package inside rt.jar Wildfly的JAXWS实现似乎忽略了bindingProvider属性com.sun.xml.ws.transport.https.client.SSLSocketFactory - Wildfly's JAXWS implementation seems to ignore bindingProvider property com.sun.xml.ws.transport.https.client.SSLSocketFactory 重定向javax.xml.ws和com.sun.xml.ws的输出日志 - Redirect output logs of javax.xml.ws and com.sun.xml.ws sun-jaxws.xml - 什么时候需要,什么时候不需要? - sun-jaxws.xml - When is it needed and when not? 没有sun-jaxws.xml的Tomcat上的JAX-WS Web服务 - JAX-WS Web service on Tomcat without sun-jaxws.xml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM