使用APT的Java Web服务。我是否需要注释处理器?哪里不对? [英] Java Web service using Apt. Do I need an annotation processor? What is wrong?
问题描述
我一直在努力做一个简单的Web服务,并一直在关注本教程一>。不幸的是我坚持。以下是我迄今所做的:
I have been trying to make a simple web service and have been following this tutorial . Unfortunately I am stuck. Here is what I have done so far:
1)我创建这个类:
package server;
import javax.jws.WebService;
@WebService
public class HelloImpl {
/**
* @param name
* @return Say hello to the person.
*/
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
2)我跑:
apt HelloImpl.java
3)我得到这样的警告:
3) I get this warning:
hostName[username:~/Desktop/webtest][534]% apt HelloImpl.java
warning: Annotation types without processors: [javax.xml.bind.annotation.XmlRootElement, javax.xml.bind.annotation.XmlAccessorType, javax.xml.bind.annotation.XmlType, javax.xml.bind.annotation.XmlElement]
1 warning
贴切的命令应(按教程)生成以下文件:
The apt command should (according to the tutorial) produce these files:
HelloServiceImpl.wsdl
schema1.xsd
classes/server/HelloImpl.class
classes/server/jaxrpc/SayHello.class
classes/server/jaxrpc/SayHelloResponse.class
classes/server/jaxrpc/SayHello.java
classes/server/jaxrpc/SayHelloResponse.java
这是什么产生的,当我叫apt:
This is what was generated when I called apt:
HelloImpl.java (not generated but it is still in the directory)
HelloImpl.class
server/jaxws/SayHello.cass
server/jaxws/SayHell.java
server/jaxws/SayHelloResponse.class
server/jaxws/SayHelloResponse.java
(丢失:)
HelloServiceImpl.wsdl
schema1.xsd
(路径也略有不同)
(the paths are also slightly different)
我怀疑是正在生成警告并没有被生成的其他文件,因为我有的注解类型,而处理器。
I suspect that the warning is being generated and the other files are not being generated because I have "Annotation types without processors:".
我觉得警告意味着它需要一个注解厂(处理器)。我知道,你可以指定一个什么出厂:
I think that the warning indicates that it needs an annotation factory (processor). I know that you can specify what a factory by:
在此输入code
-cp指定查找用户类文件和注释处理器工厂
enter code here
-cp Specify where to find user class files and annotation processor factories
我只是不确定要指定的工厂。 (或者,也许我需要配置不同的东西)。
I am just unsure of what factory to specify. (Or maybe I need to configure something differently).
推荐答案
这是5岁的教程可能有点过时。 JAX-WS 是JAX-RPC的接班人。不过,也许你需要的是,而不是运行 WSGEN 工具APT的。
That 5 year old tutorial might be a bit out of date. jax-ws is the successor to jax-rpc. Though, maybe all you need is to run the wsgen tool instead of apt.
看看这里一个小教程<一个href=\"http://stackoverflow.com/questions/1792737/in-process-soap-service-server-for-java/1793112#1793112\">http://stackoverflow.com/questions/1792737/in-process-soap-service-server-for-java/1793112#1793112
这篇关于使用APT的Java Web服务。我是否需要注释处理器?哪里不对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!