易警告:发现没有标注处理程序 [英] apt warning: no annotation processor found

查看:247
本文介绍了易警告:发现没有标注处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是自学有关Web服务现在并试图运行一个HelloWorld。我认为要建立所有的Web服务的东西,我需要运行贴切。

I am just teaching myself about web services right now and trying to run a helloWorld. I think that to setup all of the web service stuff I need to run apt.

我运行这样的:

apt HelloImpl.java -classpath /<path>/jsr181-api.jar

不过,我得到一个警告(见下文)。我需要太指定注释处理器?我认为恰当的命令应该生成多个文件,但没有发生(只产生一个.class文件)。谢谢您的帮助。

But I am getting a warning (see below). Do I need to specify an annotation processor too? I think that the apt command is supposed to generate several files but that is not happening (just generating a .class file). Thanks for the help.

警告:

warning: No annotation processors found but annotations present.
1 warning

code:

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 + "!";
   }
}

奖金问题:这是什么容易做?我认为它调用的javac?难道应该也调用注解处理器?

Bonus Question: What does apt do? I assume that it invokes javac? Is it supposed to also invoke a annotation processor?

更新:借助教程,我下面说:

The next step is to run apt on the above Java code, resulting in several artifacts:

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

我认为这是容易应产生(假设我将它传递正确的参数)。不过,我认为我需要传递一个注解处理器(?)。我真的只是想,虽然使用默认的(Web服务注解处理器)。

I think that this is what apt should be producing (assuming that I pass it the correct arguments). However I think that I need to pass it an annotation processor(?). I would really just like to use the default (web services annotation processor) though.

更新2 :也许我应该使用的asant或WSGEN?我看了看,但我没有任何的这些我的机器上..东西寻找到..也许我/在使用教程是错误的。这里是将asant参考链接:的http:// java的。 sun.com/webservices/docs/2.0/tutorial/doc/JAXWS3.html

Update 2: Maybe I should be using asant or wsgen? I looked but I don't have either of these on my machine.. Something to look into.. Maybe the tutorial I am/was using is wrong. Here is a link to the asant reference: http://java.sun.com/webservices/docs/2.0/tutorial/doc/JAXWS3.html

推荐答案

是不是一个编译器。它处理的源文件并调用注释处理器为宜。

要引用入门...

该命令行实用程序贴切,注释处理工具,查找和执行基于组指定的源文件的注释present注解处理器正在检查。

The command-line utility apt, annotation processing tool, finds and executes annotation processors based on the annotations present in the set of specified source files being examined.

您可能会遇到的源文件容易在编译的时候产生新的源文件或元数据文件。您可以运行通过的javac

You might run apt on source files to generate new source files or metadata files at build time. You can run apt via javac.

在Java注解可以一举多得。不是所有的人都需要在构建时进行处理。有些作为,可以通过仪器被用来在加载时变换类标记。大多数只是在使用能够通过内省工具使用(像许多容器和依赖注入器)运行时的标记。究竟如何使用注解取决于它来自的API。该JEE5教程介绍如何使用的WebService 注释

Annotations in Java can serve multiple purposes. Not all of them need to be processed at build time. Some serve as markers that can be used via instrumentation to transform classes at load time. Most are just used at runtime markers that can be used by introspection tools (like many containers and dependency injectors). Exactly how you use an annotation depends on the API it came from. The JEE5 tutorial describes how to use the WebService annotation.

这篇关于易警告:发现没有标注处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆