array(2) { ["docs"]=> array(10) { [0]=> array(10) { ["id"]=> string(3) "428" ["text"]=> string(77) "Visual Studio 2017 单独启动MSDN帮助(Microsoft Help Viewer)的方法" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(8) "DonetRen" ["tagsname"]=> string(55) "Visual Studio 2017|MSDN帮助|C#程序|.NET|Help Viewer" ["tagsid"]=> string(23) "[401,402,403,"300",404]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400964" ["_id"]=> string(3) "428" } [1]=> array(10) { ["id"]=> string(3) "427" ["text"]=> string(42) "npm -v;报错 cannot find module "wrapp"" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "zzty" ["tagsname"]=> string(50) "node.js|npm|cannot find module "wrapp“|node" ["tagsid"]=> string(19) "[398,"239",399,400]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400760" ["_id"]=> string(3) "427" } [2]=> array(10) { ["id"]=> string(3) "426" ["text"]=> string(54) "说说css中pt、px、em、rem都扮演了什么角色" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(12) "zhengqiaoyin" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400640" ["_id"]=> string(3) "426" } [3]=> array(10) { ["id"]=> string(3) "425" ["text"]=> string(83) "深入学习JS执行--创建执行上下文(变量对象,作用域链,this)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "Ry-yuan" ["tagsname"]=> string(33) "Javascript|Javascript执行过程" ["tagsid"]=> string(13) "["169","191"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511399901" ["_id"]=> string(3) "425" } [4]=> array(10) { ["id"]=> string(3) "424" ["text"]=> string(30) "C# 排序技术研究与对比" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "vveiliang" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(8) ".Net Dev" ["catesid"]=> string(5) "[199]" ["createtime"]=> string(10) "1511399150" ["_id"]=> string(3) "424" } [5]=> array(10) { ["id"]=> string(3) "423" ["text"]=> string(72) "【算法】小白的算法笔记:快速排序算法的编码和优化" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "penghuwan" ["tagsname"]=> string(6) "算法" ["tagsid"]=> string(7) "["344"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511398109" ["_id"]=> string(3) "423" } [6]=> array(10) { ["id"]=> string(3) "422" ["text"]=> string(64) "JavaScript数据可视化编程学习(二)Flotr2,雷达图" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "chengxs" ["tagsname"]=> string(28) "数据可视化|前端学习" ["tagsid"]=> string(9) "[396,397]" ["catesname"]=> string(18) "前端基本知识" ["catesid"]=> string(5) "[198]" ["createtime"]=> string(10) "1511397800" ["_id"]=> string(3) "422" } [7]=> array(10) { ["id"]=> string(3) "421" ["text"]=> string(36) "C#表达式目录树(Expression)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "wwym" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(4) ".NET" ["catesid"]=> string(7) "["119"]" ["createtime"]=> string(10) "1511397474" ["_id"]=> string(3) "421" } [8]=> array(10) { ["id"]=> string(3) "420" ["text"]=> string(47) "数据结构 队列_队列实例:事件处理" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "idreamo" ["tagsname"]=> string(40) "C语言|数据结构|队列|事件处理" ["tagsid"]=> string(23) "["246","247","248",395]" ["catesname"]=> string(12) "数据结构" ["catesid"]=> string(7) "["133"]" ["createtime"]=> string(10) "1511397279" ["_id"]=> string(3) "420" } [9]=> array(10) { ["id"]=> string(3) "419" ["text"]=> string(47) "久等了,博客园官方Android客户端发布" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(3) "cmt" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511396549" ["_id"]=> string(3) "419" } } ["count"]=> int(200) } 222 SSM--------------------SSM整合 - 爱码网
  1. SSM整合

Spring + SpringMVC + Mybatis整合

 

a:导入jar包

  1. Spring+ SpringMVC + MyBatis + Mybatis-spring整合包
  2. AOP联盟+织入 + c3p0 数据库连接池 + MySQL连接驱动 + jstl

SSM--------------------SSM整合

 

b:创建一个springmvc文件

<?xml version="1.0" encoding="UTF-8"?>

  <beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"

       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-3.2.xsd

      http://www.springframework.org/schema/mvc

      http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd

      http://www.springframework.org/schema/context

      http://www.springframework.org/schema/context/spring-context-3.2.xsd

      http://www.springframework.org/schema/aop

      http://www.springframework.org/schema/aop/spring-aop-3.2.xsd

      http://www.springframework.org/schema/tx

      http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

  

    <!-- 1.配置注解扫描位置 -->

    <context:component-scan base-package="com.gyf.backoffice.web.controller" />

  

  

    <!-- 2.配置注解处理映射-->

    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>

  

    <!--3.配置适配器-->

    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">

  

    </bean>

  

    <!-- 4.配置springmvc视图解析器 视图解析器解析的视频路径为:前缀 + 后缀 -->

    <bean

            class="org.springframework.web.servlet.view.InternalResourceViewResolver">

        <property name="prefix" value="/WEB-INF/views" />

        <property name="suffix" value=".jsp" />

    </bean>

  </beans>

 

 

c:在web.xml添加springmvc配置

这次我们更改默认的springmvc配置文件路径

SSM--------------------SSM整合

<servlet>

          <servlet-name>DispatcherServlet</servlet-name>

          <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

          <!-- 3.0springmvc 默认加载WEB-INF下的dispatcher-servlet.xml文件 3.2的springmvc

               加载DispatcherServlet-servlet.xml文件 -->

          <init-param>

               <!-- 修改黑底springmvc加载的配置文件路径 -->

               <param-name>contextConfigLocation</param-name>

               <param-value>classpath:springmvc.xml</param-value>

          </init-param>

          <load-on-startup>1</load-on-startup>

     </servlet>

     <servlet-mapping>

          <servlet-name>DispatcherServlet</servlet-name>

          <url-pattern>*.do</url-pattern>

     </servlet-mapping>

 

d:先配置一个Controller跑出一个页面

SSM--------------------SSM整合

SSM--------------------SSM整合

 

 

e:通过MyBatis的****生成JavaBean/Mapper

把生成的文件导入当到项目,步骤不记得可以参数MyBatis的教案

SSM--------------------SSM整合

 

f:修改ItemsMapper.java和ItemsMapper.xml

SSM--------------------SSM整合

SSM--------------------SSM整合

 

g:定义Service层接口并实现

SSM--------------------SSM整合

SSM--------------------SSM整合

 

h:配置SqlMappingConfig.xml、mybatis

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration

PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>

     <!-- 别名配置 -->

     <typeAliases>

          <!-- 批量配置别名:指定批量定义别名的类包,别名为类名(首字母大小写都可) -->

          <package name="com.gyf.backoffice.domain"/>

     </typeAliases>

     <mappers>

          <!-- 批量加载映射文件 -->

          <package name="com.gyf.backoffice.mapper"/>

     </mappers>

</configuration>

 

i:创建spring的applicaiontContext.xml

配置数据源和mybaties的session工厂

<?xml version="1.0" encoding="UTF-8"?>

<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-3.2.xsd

          http://www.springframework.org/schema/context

          http://www.springframework.org/schema/context/spring-context-3.2.xsd

          http://www.springframework.org/schema/aop

          http://www.springframework.org/schema/aop/spring-aop-3.2.xsd

          http://www.springframework.org/schema/tx

          http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

</beans>

 

j:配置c3p0数据源和mybatis的会话工厂

  

     <!-- 1.加载db配置文件  -->

     <context:property-placeholder location="classpath:db.properties"/>

 

     <!-- 2.配置c3p0数据源 -->

     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">

          <property name="driverClass" value="${jdbc.driver}"/>

          <property name="jdbcUrl" value="${jdbc.url}"/>

          <property name="user" value="${jdbc.username}"/>

          <property name="password" value="${jdbc.password}"/>

          <property name="maxPoolSize" value="30"/>

          <property name="minPoolSize" value="2"/>

     </bean>

 

     <!-- 3.让spring管理sqlsessionFactory -->

     <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactoryBean">

          <property name="dataSource" ref="dataSource"/>

          <!-- 指定配置文件位置 -->

          <property name="configLocation" value="classpath:SqlMapConfig.xml"/>

     </bean>

    

     <!-- 4.配置mapper扫描器.批量扫描创建代理对象 -->

     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

          <property name="basePackage" value="com.gyf.backoffice.mapper"/>

          <property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean"/>

     </bean>

db文件内容

jdbc.driver=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/mybatis

jdbc.username=root

jdbc.password=123456

 

k:Web.xml配置spring容器

<!-- spring的配置 -->

    <context-param>

        <param-name>contextConfigLocation</param-name>

        <param-value>classpath:applicationContext.xml</param-value>

    </context-param>

    <listener>

        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

    </listener>

 

l:添加bean的注解装配

<!-- 配置扫描注解 -->

    <context:component-scan base-package="com.gyf.backoffice"/>

 

m:ItemsService

SSM--------------------SSM整合

 

n:ItemsController

SSM--------------------SSM整合

这里可以方法items/list.do,是否可以获取数据

o:事务配置

Spring中Propagation类的事务属性详解:

REQUIRED:支持当前事务,如果当前没有事务,就新建一个事务。这是最常见的选择。

SUPPORTS:支持当前事务,如果当前没有事务,就以非事务方式执行。

MANDATORY:支持当前事务,如果当前没有事务,就抛出异常。

REQUIRES_NEW:新建事务,如果当前存在事务,把当前事务挂起。

NOT_SUPPORTED:以非事务方式执行操作,如果当前存在事务,就把当前事务挂起。

NEVER:以非事务方式执行,如果当前存在事务,则抛出异常。

NESTED:支持当前事务,如果当前事务存在,则执行一个嵌套事务,如果当前没有事务,就新建一个事务

 

<!-- 6.事务管理器 -->

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
</bean>

<!-- 6.通知 -->

    <tx:advice id="txAdvice" transaction-manager="transactionManager">

        <tx:attributes>

            <!-- 传播行为 -->

            <tx:method name="save*" propagation="REQUIRED"/>

            <tx:method name="insert*" propagation="REQUIRED"/>

            <tx:method name="delete*" propagation="REQUIRED"/>

            <tx:method name="update*" propagation="REQUIRED"/>

            <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>

            <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>

        </tx:attributes>

    </tx:advice>

   

    <!-- 7. 切面 -->

    <aop:config>

        <aop:advisor advice-ref="txAdvice"

        pointcut="execution(* com.gyf.backoffice.service.*.*(..))"/>

    </aop:config>

<!-- 5.配置事务管理器 -->

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

    <property name="dataSource" ref="dataSource"/>

  </bean>

  <!-- 6.开启事务注解-->

  <tx:annotation-driven></tx:annotation-driven>

 

 

o:添加一个保存方法测试事务

service

SSM--------------------SSM整合

controller

SSM--------------------SSM整合

 

 

相关文章:

  • 2018-11-30
  • 2020-12-27
  • 2021-01-03
  • 2020-05-19
  • 2021-08-04
  • 2019-02-27
  • 2021-11-28
猜你喜欢
  • 2019-07-07
  • 2021-08-04
  • 2020-01-10
  • 2019-12-23
  • 2019-03-17
  • 2019-07-10
  • 2018-06-09
相关资源
相似解决方案