zoukankan      html  css  js  c++  java
  • spring 注解列表

    注解 作用 例子
    @SuppressWarnings 忽略警告 类上添加此注解:@SuppressWarnings("serial"),能消除警告:The serializable class xxx does not declare a static final serialVersionUID field of type long
    在applicationContext.xml中注册<context:component-scan base-package=”pagkage1[,pagkage2,…,pagkageN]”/> 如果某个类的头上带有特定的注解【@Component/@Repository/@Service/@Controller】,就会将这个对象作为Bean注册进Spring容器 <context:component-scan base-package="cn.gacl.dao.impl,cn.gacl.service.impl,cn.gacl.action"/>
    @Controller 对应表现层的Bean,也就是Action
    @Scope("prototype") 或 @Scope("singleton") @Scope("prototype")表示将Action的范围声明为原型,可以利用容器的scope="prototype"来保证每一个请求有一个单独的Action来处理,避免struts中Action的线程安全问题;spring 默认scope 是单例模式(scope="singleton")
    @Service 对应的是业务层Bean
    @Repository 对应数据访问层Bean
    @Component @Component 是 @Controller @Service @Repository 的父类,不能在语义上表明这个类所处的层级,因此不推荐使用
  • 相关阅读:
    开源的免费的对比工具
    win10 git bash 配置
    Java SSH 不使用终端也能调用环境变量中的指令
    MySQL WITH ROLLUP
    docker安装postgres
    开源的应用容器引擎
    清除浮动有哪几种方法
    js中的yield
    git的速学了解
    string/stringBuffer/StringBuilder的区别
  • 原文地址:https://www.cnblogs.com/cag2050/p/7112350.html
Copyright © 2011-2022 走看看