当前位置: 首页 > news >正文

手机网站开发升上去做网站需要提交

手机网站开发升上去,做网站需要提交,百度云架设网站,在什么文件中加入什么代码告诉搜索引擎蜘蛛网站地图的文件位置?Java注解 注解介绍元注解RetentionTargetDocumentedInherited接口类测试结果 注解介绍 Java注解#xff08;Annotation#xff09;是一种元数据#xff08;Metadata#xff09;的形式#xff0c;它可以被添加到Java代码中的类、方法、变量、参数等元素上#xff0c;以提… Java注解 注解介绍元注解RetentionTargetDocumentedInherited接口类测试结果 注解介绍 Java注解Annotation是一种元数据Metadata的形式它可以被添加到Java代码中的类、方法、变量、参数等元素上以提供关于程序代码的额外信息。 在Java中注解并不是一个Java类而是一个特殊的接口类型(默认继承java.lang.annotation.Annotation接口)其实例在编译时被创建并且在程序运行过程中可以通过反射获取相关信息。 注解里面定义的方法代表的注解的成员属性可以指定默认值(不指定默认值时使用时必须指定对应的值)。在注解被使用时可以指定具体的的值在编译时会自动创建代理的注解对象这个对象的属性不可修改(immutable)。 Target({ElementType.TYPE, ElementType.METHOD}) Retention(RetentionPolicy.RUNTIME) Documented Conditional({OnClassCondition.class}) public interface ConditionalOnClass {Class?[] value() default {};String[] name() default {}; } 元注解 Java中元注解是用来修饰其它注解的注解。元注解是用来定义其它注解行为的注解。Java提供了常用的元注解Retention、Target、Documented、Inherited。 Retention retention保留保持。 Retention保留注解策略只有这个元注解作用于注解时才有效如果将元注解类型作用于另一个注解类型的成员属性(成员变量)则无效。 保留策略RetentionPolicy.SOURCE、RetentionPolicy.CLASS、RetentionPolicy.RUNTIME。 RetentionPolicy.SOURCE注解在编译时会被丢弃。只保留在源代码级别可以用于编译器的静态检查和处理。RetentionPolicy.CLASS注解被保留在class文件中但是运行时不可见不能通过反射获取。对编译器可见但是运行时不会产生任何效果。缺省的默认保留策略。RetentionPolicy.RUNTIME编译后被保存在class文件中并且运行时能提供反射获取到。 Documented Retention(RetentionPolicy.RUNTIME) Target(ElementType.ANNOTATION_TYPE) public interface Retention {// 返回注解保留的策略RetentionPolicy value(); } 继承Retention注解 package com.oycm.spring_data_jpa.annotations.retention;import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy;Retention(RetentionPolicy.SOURCE) public interface RetentionSource { } package com.oycm.spring_data_jpa.annotations.retention;import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy;Retention(RetentionPolicy.SOURCE) public interface RetentionClass {} package com.oycm.spring_data_jpa.annotations.retention;import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy;Retention(RetentionPolicy.RUNTIME) public interface RetentionRuntime {ClassRetentionClass value(); } package com.oycm.spring_data_jpa.annotations.retention;import java.lang.annotation.Annotation; import java.lang.reflect.Field;/*** author ouyangcm* create 2024/2/26 15:52*/ RetentionSource RetentionClass RetentionRuntime(value RetentionClass.class) public class RetentionTest {RetentionSourceRetentionClassRetentionRuntime(value RetentionClass.class)private String member;RetentionSourceRetentionClassRetentionRuntime(value RetentionClass.class)private static String staticMember;public static void main(String[] args) {ClassRetentionRuntime runtimeClass RetentionRuntime.class;ClassRetentionTest clazz RetentionTest.class;Annotation[] annotations clazz.getAnnotations();for (Annotation annotation : annotations) {System.out.println(annotation);}Field[] currentClassFields clazz.getDeclaredFields();for (Field currentClassField : currentClassFields) {System.out.println(属性名: currentClassField.getName());Annotation[] fieldAnnotations currentClassField.getAnnotations();for (Annotation fieldAnnotation : fieldAnnotations) {System.out.println(注解: fieldAnnotation.annotationType().getName());}}} } 注意反射获取的Annotation是一个代理对象可以使用annotationType()方法获取真正的注解对象类信息。 Target Documented Retention(RetentionPolicy.RUNTIME) Target(ElementType.ANNOTATION_TYPE) public interface Target {// 注解目标类型数组ElementType[] value(); } Target注解用于指定注解可以应用的目标类型。类型有ElementType.TYPE(类、接口(注解)、枚举等)、ElementType.FIELD(静态或非静态成员变量)、ElementType.METHOD(普通方法)、ElementType.PARAMETER(方法参数)、ElementType.CONSTRUCTOR(构造方法)、ElementType.LOCAL_VARIABLE(局部变量)、ElementType.ANNOTATION_TYPE(注解)、ElementType.PACKAGE(包)、ElementType.TYPE_PARAMETER(泛型)、ElementType.TYPE_USE(用于使用类型的任何地方)。 // 不能作用于其他类型上,只能作为其他注解的变量使用 Target({}) public interface MemberType {... }// 类型重复出现,编译报错 Target({ElementType.FIELD, ElementType.METHOD, ElementType.FIELD}) public interface Bogus {... } Documented Documented Retention(RetentionPolicy.RUNTIME) Target(ElementType.ANNOTATION_TYPE) public interface Documented { } 指示被标注的自定义注解是否应该包含再Java文档中。一个注解使用了Document注解标注那么使用javadoc工具生成文档时这个注解的信息会被包含在文档中。 Inherited Inherited继承的遗传的。 表示类的注解是可继承的使用getAnnotation()会自动查询该类的父类以获取所有的注解直到Object类这个元注解只在作用于类注解时才生效。 Documented Retention(RetentionPolicy.RUNTIME) Target(ElementType.ANNOTATION_TYPE) public interface Inherited { } Inherited Retention(RetentionPolicy.RUNTIME)// 不可省略,不然获取不到 Target(ElementType.TYPE) public interface MyInherited { } 接口 package com.oycm.spring_data_jpa.annotations.inherited;MyInherited public interface InheritedInterface { } package com.oycm.spring_data_jpa.annotations.inherited;/*** author ouyangcm* create 2024/2/26 17:22*/ public class InheritedInterfaceImpl implements InheritedInterface{ } 类 package com.oycm.spring_data_jpa.annotations.inherited;/*** author ouyangcm* create 2024/2/26 17:22*/ MyInherited public class InheritedSuper { } package com.oycm.spring_data_jpa.annotations.inherited;/*** author ouyangcm* create 2024/2/26 17:22*/ public class InheritedSuperSub extends InheritedSuper{ } 测试结果 package com.oycm.spring_data_jpa.annotations.inherited;/*** author ouyangcm* create 2024/2/26 17:21*/ public class InheritedTest {public static void main(String[] args) {ClassInheritedInterface inheritedInterfaceClass InheritedInterface.class;ClassInheritedInterfaceImpl inheritedInterfaceClassImpl InheritedInterfaceImpl.class;// 这里获取到Annotation对象仍然是代理,不过两个是同一个对象.annotationType()可以获取真正的Class对象System.out.println(inheritedInterfaceClass.getAnnotation(MyInherited.class));System.out.println(inheritedInterfaceClass.getDeclaredAnnotation(MyInherited.class));System.out.println(inheritedInterfaceClassImpl.getAnnotation(MyInherited.class));System.out.println(inheritedInterfaceClassImpl.getDeclaredAnnotation(MyInherited.class));ClassInheritedSuper inheritedSuperClass InheritedSuper.class;ClassInheritedSuperSub inheritedSuperSubClass InheritedSuperSub.class;System.out.println(inheritedSuperClass.getAnnotation(MyInherited.class));System.out.println(inheritedSuperClass.getDeclaredAnnotation(MyInherited.class));System.out.println(inheritedSuperSubClass.getAnnotation(MyInherited.class));System.out.println(inheritedSuperSubClass.getDeclaredAnnotation(MyInherited.class));// 只能获得自己的注解} }
http://www.dnsts.com.cn/news/15086.html

相关文章:

  • 猪八戒做网站排名徐州网站建设xzwzjs
  • 为什么浏览器打不开一些网站长沙人才市场招聘
  • 软件开发建设网站南通网站的优化
  • 服务器吗放几个网站太原网站建设vhuashi
  • 网站备案名称中国开头郑州怎么做外贸公司网站
  • 淮安公司网站建设wordpress文章添加字段不重复
  • 网站标题栏做多大画网页
  • 怎样查看网站关键词电商培训机构有哪些?哪家比较好
  • 如何将网站部署到服务器市场监督管理局上班时间
  • wordpress 网站关键词个人网页制作实验报告
  • 做公司网站怎么做在线制作ppt免费
  • 网站建设需要的服务器北京网站主题制作
  • 漳州做网站优化域名主机基地
  • 网站浮动广告怎么做wordpress宠物主题
  • 网站开发工资多少稳定么义乌正规自适应网站建设首选
  • seo排行榜年度10佳网站必应搜索引擎怎么样
  • 昆明seo网站建设莆田关键词优化报价
  • 网站建设需要那种技术网站是别人做的域名自己怎么续费
  • PHP网站开发简单实例wordpress cron原理
  • 好看的商城网站设计建网站优势
  • 手机免费创建网站的软件网站底部留言代码
  • 开公司先建设网站免费网站软件哪个好
  • 网站视频提取软件app简洁企业网站asp
  • 青岛网站建设博采网络从事广告设计需要学什么
  • 可以查企业备案的网站网页设计题材
  • 网站建设创客温州网站制作要多少钱
  • 网站模板和源码商标注册查询一览表
  • 网站建设最新教程视频企业运营管理师
  • 网页设计作业怎么做网站wordpress置顶不重复
  • 网站建设丶金手指a排名15网站在哪里设置关键词