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配置文件复制到项目里




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

  • 相关阅读:
    C# 提取方法重构
    防抖和节流
    利用Object.keys快速循环对象
    MVVM深入理解---小白速会
    异步组件使用详解
    动态组件使用详解
    Vue.$nextTick详解
    深入理解vue .sync修饰符
    vue计算属性---快速上手
    grid-layout 网格布局--快速上手
  • 原文地址:https://www.cnblogs.com/wangjunwei/p/11386272.html
Copyright © 2011-2022 走看看