zoukankan      html  css  js  c++  java
  • 阶段3 3.SpringMVC·_07.SSM整合案例_03ssm整合之编写Spring框架

    做整合要保证每个框架单独使用
    先搭建Spring的框架,然后再整合别的框架。Spring是业务层的框架

    spring的配置文件




    这就表示是spring的配置文件

    默认的约束不够,需要修改。

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    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.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd">

    开启注解扫描

    如果配置了扫描cn.itecast下的包,

    扫描这里面所有的包

    spring只负责业务层和持久层部分。controller不管,交给SpringMvc去处理。
    配置哪些注解不扫描。里面一共有下面两个标签。exclude就是不扫描的





    这里先把controller删掉。

    去搜索controller的全路径名

    选中Controller右键。Copy reference 复制全路径

    把全路径名粘贴过来就可以了。这就表示以后Controller注解就不扫描

    Service上加上注解

    这样就是把Service这个类交给了IOC容器进行了管理

    测试

    新建包test。新建类testSpring

    单元测试的注解

    把junit的包的范围改成complie

    测试类就自动导入进来了。



    执行测试方法

    控制台输出。上面的红色是警告标示没有log4j的配置文件。

    以上说明spring的环境,就搭建成功了

    log4j配置文件

    log4j.properties配置文件复制到项目里




    这样就没有红色的警告了。
     

  • 相关阅读:
    day06-for循环补充,可变与不可变类型,数字,字符串和列表的使用
    day05-while循环和for循环的使用
    day04-运算符,流程控制之if和input()用户交互功能
    day03-变量,基本数据类型,基本运算符
    day02-python和计算机介绍2
    day01-python和计算机介绍1
    仓库
    四则运算
    异常处理
    动手动脑3
  • 原文地址:https://www.cnblogs.com/wangjunwei/p/11386272.html
Copyright © 2011-2022 走看看