![](/img/trans.png)
[英]Can't build javafx project with gradle in intellij idea
[英]Can't use generated classes from build folder with IntelliJ Idea and Gradle
I'm trying to follow this guide (consuming a SOAP web service) with IntelliJ Idea and Gradle - https://spring.io/guides/gs/consuming-web-service/#initial
我已經有了 SOAP 服務器,它工作正常,我可以在我的本地主機上看到我的 WSDL。
我重復了指南中的每一步,但是當談到“創建 [...] 服務客戶端”時,我遇到了一些問題。 我確實有一個名為“generated-sources”的文件夾,它包含我的類,從 WSDL 生成。 但我不能在“服務客戶端”中使用這些類(好像 Idea 看不到它們)。
這是我的build.gradle :
plugins {
id 'org.springframework.boot' version '2.2.0.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
jaxb
}
repositories {
mavenCentral()
}
task genJaxb {
ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
ext.classesDir = "${buildDir}/classes/jaxb"
ext.schema = "http://localhost:8080/ws/author.wsdl"
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,
package: "com.example.consumingwebservice.wsdl") {
arg(value: "-wsdl")
produces(dir: sourcesDir, includes: "**/*.java")
}
javac(destdir: classesDir, source: 11, target: 11, 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")
}
}
}
}
}
dependencies {
implementation ('org.springframework.boot:spring-boot-starter-web-services') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
implementation 'org.springframework.ws:spring-ws-core'
// For Java 11:
implementation 'org.glassfish.jaxb:jaxb-runtime'
compile(files(genJaxb.classesDir).builtBy(genJaxb))
jaxb "com.sun.xml.bind:jaxb-xjc:2.1.7"
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
bootJar {
baseName = 'gs-consuming-web-service'
version = '0.0.1'
}
這是我的截圖- https://img.techpowerup.org/200624/2687.jpg
Alt + Enter 提供創建新的 class,並導入導致此:img.techpowerup.org/200624/2344.jpg
我將非常感謝任何幫助。
這也是Maven用戶的問題。 所以對於Maven用戶來說,解決方法很簡單
然后,Intellij 會自動將生成的源導入到項目中。
Fot Gradle 用戶,過程可能相同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.