我需要注释处理器吗

我需要注释处理器吗

本文介绍了使用 Apt 的 Java 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) 我创建了这个类:

1) I created this class:

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) 我收到此警告:

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

apt 命令应该(根据教程)生成这些文件:

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

(路径也略有不同)

我怀疑正在生成警告而没有生成其他文件,因为我有没有处理器的注释类型:".

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:

在此处输入代码-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.

看看这里的迷你教程 进程内Java SOAP 服务服务器

这篇关于使用 Apt 的 Java Web 服务.我需要注释处理器吗?怎么了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:59