草庐IT

annotation

全部标签

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 - 春+ hibernate : LocalSessionFactoryBean - NoSuchMethodError: org. hibernate.cfg.annotations.reflection.XMLContext

我正在尝试将Hibernate4.0.0.FINAL与Spring3.1.0.RELEASE集成使用@Configuration。之后出现这个问题:BeanCreationException:Errorcreatingbeanwithname'alertsSessionFactoryBean'NoSuchMethodError:org.hibernate.cfg.annotations.reflection.XMLContext$Default.getDelimitedIdentifier()Ljava/lang/Boolean;这是我的PersistenceHibernateConf

Java 和@annotations

在使用Java注释时,有些事情我不确定是否理解。这是一个例子:我创建了一个@Log注释并用它添加了一些功能(每个用@Log注释的方法在执行该方法之前都会运行一些日志)。现在我正在创建一个新的@SuperLog注释,如下所示:@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.METHOD)@Logpublic@interfaceSuperLog{............}这个@SuperLog必须提供@Log所做的所有内容,以及一些特定于@SuperLog的额外内容。不幸的是,当我执行一些用@SuperLog注释的方法时,特定于

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