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配置和注释混合使用

  • 相关阅读:
    17.异常(三)之 e.printStackTrace()介绍
    16.异常(二)
    15.异常(一)
    AuthCodeTool验证码
    FileUploadTool
    JdbcTool
    myeclipse-java项目转换成web项目
    中文注释乱码change
    css鼠标样式
    java script 弹出框
  • 原文地址:https://www.cnblogs.com/gongxr/p/7954534.html
Copyright © 2011-2022 走看看