IntelliJ / JDK 11:找不到符号name()接口java.lang.annotation.Annotation

大约8:

我有这个简单的代码:

String tableName = MyEntity.class.getAnnotation( javax.persistence.Table.class ).name();

但是IntelliJ强调了该方法name()不存在的事实Cannot resolve method "name()"

在编译过程中,我也会收到此错误消息:

Error:(29, 68) java: cannot find symbol
  symbol:   method name()
  location: interface java.lang.annotation.Annotation

我看到了许多使用此方法的示例代码,这里一个示例:https : //stackoverflow.com/a/1320890/6643803我缺少什么?

谢谢

Berto99:

正如你可以看到这里有没有name()内部函数Annotation接口

您可能需要强制转换:

Table table = MyEntity.class.getAnnotation(javax.persistence.Table.class);
String tableName = table.name();

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

的IntelliJ:如何添加java.annotation模块javax.annotation.PostConstruct

javax.annotation中类和Java JDK 11

java.lang.NoSuchMethodError:org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava / lang / annotation / Annotation;)Z

引起原因:java.lang.ClassNotFoundException:com.sun.xml.bind.v2.model.annotation.AnnotationReader

IntelliJ-Java:找不到JDK'1.8'

Spring / Java错误:JDK 1.5及更高版本上的名称空间元素'annotation-config'...

ClassNotFoundException:javax.annotation.Generate with JDK 11

AWS SQS:java.lang.NoClassDefFoundError:com / fasterxml / jackson / annotation / JsonMerge?

在javax.annotation中找不到@ Nullable。*

java.lang.NoSuchMethodError org.springframework.core.annotation.AnnotationUtils.getAnnotation

IntelliJ-找不到模块:java.xml.ws.annotation

java.lang.NoSuchMethodError:org.springframework.beans.factory.annotation.AnnotatedBeanDefinition.setRole(I)V

Intellij找不到JDK

引起原因:java.lang.ClassNotFoundException:org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer

android studio 3.1警告:规则`-keep public class *扩展了java.lang.annotation.Annotation {

java.lang.NoClassDefFoundError:org / springframework / messaging / handler / annotation / support / MessageHandlerMethodFactory

java.security.AccessControlException:访问被拒绝(“ java.lang.RuntimePermission”“ accessClassInPackage.sun.reflect.annotation”)

java.lang.annotation.IncompleteAnnotationException:org.terracotta.statistics.Statistic缺少元素类型

从android java.lang.NoClassDefFoundError中的命令行获取错误:javax / annotation / Generated

找不到'mvc:annotation-driven'的声明

从类对java.lang.annotation.Annotation的引用?

在运行时使用java.lang.annotation在Spring中检索bean

java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value

Spring Redis 集成中的 java.lang.annotation.AnnotationFormatError

java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass 同时使用 Hibernate Annotation 和 Maven

错误:嵌套异常是 java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge

错误:(15, 30) java: incompatible types: com.sun.research.ws.wadl.Param 无法转换为 java.lang.annotation.Annotation

获取 java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy

接受 SDK 许可时出现“java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema”