zoukankan      html  css  js  c++  java
  • Spring注解开发简要步骤

    1、除spring基本包外还需要下载AOP包

    spring-aop-4.2.4.RELEASE.jar

    2、导入约束(最后两行)

    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:contexnt="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    3、指定注释自动扫描的包,自动注入包中有注解的类

    <contexnt:component-scan base-package="org.helloworld"></contexnt:component-scan>

    4、在扫描的类上加入注释标签

    @Component、@Service等等

    5、注入引用

    @Autowired   自动注释
    @Resource(name = "user") 指定名称

    备注:也可以XML配置和注释混合使用

  • 相关阅读:
    Uva1595 对称轴
    Uva712 S树
    Uva673 平衡的括号
    leetcode102 二叉树的层次遍历
    Uva10191 复合词
    C++ multimap的用法
    Uva1103 古代象形符号
    UVa10763 交换学生
    C++ 优先级队列 priority_queue
    ios,zepto穿透解决方案
  • 原文地址:https://www.cnblogs.com/gongxr/p/7954534.html
Copyright © 2011-2022 走看看