最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JSP 中Spring組合注解與元注解實例詳解

 更新時間:2017年03月29日 14:22:20   作者:FEINIK  
這篇文章主要介紹了JSP 中Spring組合注解與元注解實例詳解的相關(guān)資料,需要的朋友可以參考下

JSP 中Spring組合注解與元注解實例詳解

摘要: 注解(Annotation),也叫元數(shù)據(jù)。一種代碼級別的說明。它與類、接口、枚舉是在同一個層次。它可以聲明在包、類、字段、方法、局部變量、方法參數(shù)等的前面,用來對這些元素進(jìn)行說明

1. 可以注解到別的注解上的注解稱為元注解,被注解的注解稱為組合注解,通過組合注解可以很好的簡化好多重復(fù)性的注解操作

2. 示例組合注解

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@ComponentScan
public @interface GroupAnnotation {
  String[] value() default {};
}

代碼解釋:組合@Configuration 與 @ComponentScan 元注解,并覆蓋value參數(shù)

3. 編寫普通Bean

@Servicepublic class DemoService
 { 
 public void sys()
 {   System.out.println("組合注解示例"); 
 }
}

4. 使用組合注解的配置類

@GroupAnnotation("com.xuanwu.annotation")
public class DemoConfig {
}

5. 運(yùn)行

public class Main {
  public static void main(String[] args) {
   AnnotationConfigApplicationContext context = new
      AnnotationConfigApplicationContext(DemoConfig.class);
   DemoService demoService = context.getBean(DemoService.class);
   demoService.sys();
  }
}

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論

乌兰县| 集贤县| 静乐县| 厦门市| 芷江| 公主岭市| 拜泉县| 隆安县| 汤原县| 龙山县| 湖口县| 宁阳县| 长武县| 错那县| 高州市| 宝清县| 台南市| 乳源| 巴彦县| 台东县| 迭部县| 乌鲁木齐县| 贺州市| 当雄县| 册亨县| 漯河市| 永州市| 成安县| 渝北区| 江华| 新安县| 清苑县| 城口县| 阿拉善左旗| 沽源县| 上犹县| 永登县| 沁阳市| 宁明县| 民乐县| 乌兰浩特市|