设为首页 加入收藏

TOP

基于IDEA实现SSM整合框架的搭建配置流程(一)
2019-09-03 02:23:55 】 浏览:45
Tags:基于 IDEA 实现 SSM 整合 框架 搭建 配置 流程

1、创建数据库表,以员工信息表为例子:

 

DROP TABLE IF EXISTS `em_info`;
CREATE TABLE `em_info` (
    `em_id` INT(50) NOT NULL AUTO_INCREMENT COMMENT '员工ID',
    `em_name` VARCHAR(100) NOT NULL COMMENT '员工姓名',
    `em_sex` VARCHAR(30) NOT NULL COMMENT '性别',
    `em_birthday` DATE NOT NULL COMMENT '出生日期',
    `em_hiredate` DATE NOT NULL COMMENT '入职日期',
    `em_salary` DOUBLE NOT NULL COMMENT '工资',
    PRIMARY KEY (`em_id`)
    
)ENGINE=INNODB DEFAULT CHARSET=utf8mb4;
 
INSERT INTO `em_info` VALUES (NULL,'小李飞刀','男','1999-2-8','2019-6-6','9999');

  

 

 

2、创建maven工程

   

 

2.1创建Modulewebservicedaodomainutils子模块)

 

 

注意创建web子模块需要选择骨架,如下:

 

 

 

2.2、在domain子模块下创建实体类员工信息表Em_info,并提供getset方法

 

 

 

 

2.3DAO下创建IEm_infoDao接口,写查找方法findAll()。需要连续两次快捷键Alt+Enter,添加依赖和导入,导包才消除红色不报错

 

 

 

 

 

2.4、同2.3步奏,service下创建IEm_infoService接口,写查找方法findAll()。需要连续两次快捷键Alt+Enter,添加依赖和导入,导包才消除红色不报错。

 

2.5创建service实体类,实现接口,重写方法

 

 

 

 

 

2.6web.Mian包下手动创建javaresources两个包并指定为源码包和资源部

 

 

resouces包下创建applicationContext.xmlspring-mvc.xml文件

 

 

2.7applicationContext.xml导入约束

<?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.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">
    
    
    
    
    
</beans>

  

 

2.7.1、在添加下面配置扫描servicedao和配置连接池

<!-- 开启注解扫描,管理service和dao -->
<context:component-scan base-package="com.fzj.ssm.service">
</context:component-scan>
<context:component-scan base-package="com.fzj.ssm.dao">
</context:component-scan>

<context:property-placeholder location="classpath:db.properties"/>
<!-- 配置连接池 -->
<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}" />
</bean>
<!-- 把交给IOC管理 SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dat
首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Mysql框架---HMySql 下一篇Spring框架的AOP编程,最通俗的语..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目