wsimport .wsdl:为什么生成 .class 文件而不是 .java 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20137422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
wsimport .wsdl : why generating .class files and not .java files?
提问by
I have a wsdl named as abc.wsdl
我有一个名为 abc.wsdl 的 wsdl
when I tried to generate the SEI Interface java files by this command
当我尝试通过此命令生成 SEI 接口 java 文件时
wsimport abc.wsdl
It generates .class files in package path a.b.c.d
它在包路径 abcd 中生成 .class 文件
but it has not generated any .java files .
但它没有生成任何 .java 文件。
Can you please tell me Why I was not able to generate the .java files ?
你能告诉我为什么我不能生成 .java 文件吗?
Actually I am new to .wsdl files.
其实我是 .wsdl 文件的新手。
Is it specified somewhere in .wsdl file to generate .class file and not .java file ?
是否在 .wsdl 文件中的某处指定生成 .class 文件而不是 .java 文件?
AND
和
How I can generate .java file ?
我如何生成 .java 文件?
回答by Tarmo
By default wsimport generates only classes but it can be used to generate sources too with -s flag. For example make a folder srcto your to-be-generated classes root folder and execute a command like this:
默认情况下 wsimport 只生成类,但它也可以使用 -s 标志生成源。例如在你要生成的类根文件夹中创建一个文件夹src并执行如下命令:
wsimport -s src http://example.com/webservice?wsdl
This way your classes will be as before but your sources will be on src folder. Additional info about different wsimport flags can be found by entering wsimport -help on command line.
这样您的类将和以前一样,但您的源将位于 src 文件夹中。通过在命令行上输入 wsimport -help 可以找到有关不同 wsimport 标志的其他信息。
回答by Aleksandr Kravets
wsimport
utility from JDK 1.7 does generate java
files but removes them after byte-code generation leaving class
files only. You can use option -keep
to specify that you want to have both.
wsimport
JDK 1.7 中的实用程序确实会生成java
文件,但会在生成字节码后将它们删除,只留下class
文件。您可以使用选项-keep
来指定您想要同时拥有两者。
wsimport -keep http://example.com/webservice?wsdl
回答by Aram Paronikyan
If you don't need classes, you can use -Xnocompile
option of wsimport tool.
如果不需要类,可以使用-Xnocompile
wsimport 工具的选项。