apt 警告:未找到注释处理器 [英] apt warning: no annotation processor found

查看:24
本文介绍了apt 警告:未找到注释处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在只是在自学 Web 服务并尝试运行 helloWorld.我认为要设置我需要运行 apt 的所有 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

但我收到警告(见下文).我是否也需要指定注释处理器?我认为 apt 命令应该生成几个文件,但这并没有发生(只是生成一个 .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

代码:

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

额外问题:apt 有什么作用?我假设它调用 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

我认为这就是 apt 应该产生的(假设我传递了正确的参数).但是我认为我需要给它传递一个注释处理器(?).不过,我真的只想使用默认值(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

推荐答案

apt 不是编译器.它处理源文件并调用 注释处理器 视情况而定.

引用入门...

命令行实用程序 apt 是注释处理工具,它根据正在检查的一组指定源文件中存在的注释来查找并执行注释处理器.

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.

您可以在源文件上运行 apt 以在构建时生成新的源文件或元数据文件.您可以运行 apt 通过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.

这篇关于apt 警告:未找到注释处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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