java注解技术是什么技术

解决方案 »

  1.   

    Annotation ,在JPA Spring JUnit里面都有用到,利用Annotation对java的类、字段、方法等进行元数据的标记,然后提取元数据做一些事情,你自己google一下就能知道更多
      

  2.   

    通俗的说,注解(annotation)是在代码中留记号,然后其他的程序就可以识别这些记号,做些特殊的处理动作,如
    依赖注入,
    再如,
    自动部署
      

  3.   

    Annotation使用起来很方便以spring中的注解为例
    @Service               • 例如               @Service
                  public class SoftCreateServiceImpl implements ISoftCreateService {}
                  • 或者
                  @Service("softCreateServiceImpl")
                  • 说明               @Service 负责注册一个bean 到spring 上下文中,bean 的ID 默认为类名称开头字母小写 
      

  4.   

    @Autowired               • 例如               @Autowired
                  private ISoftPMService softPMService;
                  • 或者        @Autowired(required=false)
         private ISoftPMService softPMService = new SoftPMServiceImpl();
             • 说明     @Autowired 根据bean 类型从spring 上线文中进行查找,注册类型必须唯一,否则报异常。与@Resource 的区别在于,@Resource 允许通过bean 名称或bean 类型两种方式进行查找@Autowired(required=false) 表示,如果spring 上下文中没有找到该类型的bean 时, 才会使用new SoftPMServiceImpl(); @Autowired 标注作用于 Map 类型时,如果 Map 的 key 为 String 类型,则 Spring 会将容器中所有类型符合 Map 的 value 对应的类型的 Bean 增加进来,用 Bean 的 id 或 name 作为 Map 的 key。@Autowired 还有一个作用就是,如果将其标注在 BeanFactory 类型、ApplicationContext 类型、ResourceLoader 类型、ApplicationEventPublisher 类型、MessageSource 类型上,那么 Spring 会自动注入这些实现类的实例,不需要额外的操作。使用注解可以极大减少java代码,注解是java的一大特性http://www.iteye.com/topic/973726
    lz可以参考这里