草庐IT

Annotation

全部标签

java - 错误 : annotation type not applicable to this kind of declaration

我正在尝试编译我正在编写的JavaWeb应用程序,但我遇到了编译错误,我不知道该如何处理。通过谷歌搜索,我发现了thisSO问题,但是提问者使用的是EJB,而我的错误是在JPA实体类中。这是Maven构建错误。[INFO]------------------------------------------------------------------------[INFO]BUILDFAILURE[INFO]------------------------------------------------------------------------[INFO]Totaltime:3

java.lang.IllegalArgumentException : error Type referred to is not an annotation type 异常

我得到以下建议:-@Before(value="@annotation(loggable)",argNames="joinPoint,loggable")publicvoidbefore(JoinPointjoinPoint,Loggableloggable){Classclazz=joinPoint.getTarget().getClass();MethodSignaturemethodSignature=(MethodSignature)joinPoint.getSignature();Methodmethod=methodSignature.getMethod();Stringm

java - Interface Annotation 不接受 application.properties 值

我开发了一个简单的注释界面@Target(ElementType.TYPE)@Retention(RetentionPolicy.RUNTIME)public@interfaceCustomAnnotation{Stringfoo()default"foo";}然后我测试它并注释一个类@CustomAnnotationpublicclassAnnotatedClass{}并使用方法调用它publicvoidfoo(){CustomAnnotationcustomAnnotation=AnnotatedClass.class.getAnnotation(CustomAnnotation.

java - 包 javax.servlet.annotation 不存在

我定义了一些如下导入,如下图所示。我想知道,如何消除"packagejavax.servlet.annotationdoesnotexist"错误。我目前正在Netbeans7.4中从事“JavaWeb”类型的项目。.其次,我相信,上述错误是我第二个与“WebServlet”相关的错误背后的原因,如上图所示(第44行)。请告诉我如何解决这个问题。阅读其他一些帖子likethisone,但我相信他们没有使用Netbeans,并且不确定我是否应该像帖子中提到的那样更新tomcat。servletapijar文件的位置如下图所示: 最佳答案

java - 注释 - 在构建时读取元素值

是否可以在构建时读取注释元素的值?例如,如果我定义了以下注释:public@interfaceState{Stringstage();}然后我在类中注释一个方法,如下所示:publicclassFoo{@State(stage="build")publicStringdoSomething(){return"doingsomething";}}如何在构建时在注释处理器中读取@State注释元素“阶段”的值?我有一个如下构建的处理器:@SupportedAnnotationTypes(value={"State"})@SupportedSourceVersion(SourceVersio

使用 findbugs 的 java 编译错误。 com.sun.tools.javac.code.Symbol$CompletionFailure : class file for javax. annotation.meta.When not found

我正在尝试使用findbugs1.3.2的注释。我在一个简单的测试中使用了edu.umd.cs.findbugs.annotations.NonNull注释,它工作正常。但是,现在我有一个大项目,由子模块组成,使用maven,我通过在某个java文件中导入该注释得到以下编译错误:com.sun.tools.javac.code.Symbol$CompletionFailure:classfileforjavax.annotation.meta.Whennotfound可能是什么问题?我尝试在所有子模块中添加findbugs依赖项。也许它与jsr305冲突?我看到我们的依赖项之一使用js

java - 是上下文 :annotation-config an alternative to @AutoWired?

我可以将context:annotation-config放在我的XML配置中,它会自动注入(inject)bean类而不需要任何注释是否正确?所以不要使用这些注解类型:publicclassMailman{privateStringname;@AutowiredprivateParcelParcel;publicMailman(Stringname){this.name=name;}@AutowiredpublicvoidsetParcel(ParcelParcel){this.Parcel=Parcel;}@AutowiredpublicvoiddirectionsToParcel

java - @XmlElement 是否可以使用非标准名称注释方法?

这就是我正在做的:@XmlType(name="foo")@XmlAccessorType(XmlAccessType.NONE)publicfinalclassFoo{@XmlElement(name="title")publicStringtitle(){return"hello,world!";}}JAXB提示:com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:2countsofIllegalAnnotationExceptionsJAXBannotationisplacedonamethodthatisnotaJAX

java - 冒号的含义(:) inside @Path annotation

我是Restful服务的新手。我正在查看代码并找到了这一行@GET@Path("{image:image/.*}")谁能解释一下上述语法的含义和用法? 最佳答案 @Path符号支持普通字符串匹配路径或正则表达式匹配模式。在你的情况下@Path("{image:image/.*}")似乎只是匹配的模式Pathparam{image}withanypatternlikeimage/.*,whichbasicallytranslatestoimage/anything,anythingheredoesnotrefertotheword'a

java - 在 Annotation Processor for java 中发现方法调用的类

我正在为我们的构建系统编写一些工具,以对属于包含某些注释的类的方法执行一些严格的调用约定。我正在使用编译器树API...我想知道的是,在遍历“树”时,您如何判断MethodInvocation的类/接口(interface)的类型。我将TreePathScanner子类化为:@OverridepublicObjectvisitMethodInvocation(MethodInvocationTreenode,Treestrees){}我希望有一种方法可以告诉您尝试调用方法的类(或接口(interface))的类型。我会以错误的方式解决这个问题吗?感谢您的任何想法...