第一阶段:

1、用PowerDesign建数据模型,并导出SQL文件;

2、将SQL文件导入到MySQL客户端,建立表格;

  MySQL数据远程访问:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

如果是固定IP:grant all privileges on *.* to 'root'@'192.168.41.100'identified by '123456' with grant option;

//推送设置到内存或重启服务器也行
mysql>FLUSH PRIVILEGES

3、使用MyBatis框架,搭建DAO层:----------------------------Mybatis----------------------

  1)数据库连接的信息:驱动类、连接地址、用户名、密码
<jdbcConnection driverClass="com.mysql.jdbc.Driver"        connectionURL="jdbc:mysql://192.168.41.100:3306/testtest" userId="root"    password="123456"></jdbcConnection>

  2)targetPackage="com.softjx.model"

  3)把表名与类名对应
<table schema="testtest" tableName="school" domainObjectName="School"></table>

  4)运行GeneratorSqlmap.java生成dao和model

第二阶段:

1、在MyEclipse上新建一个Web项目,并导入ssm所需的jar包,放在WEB-INF/lib目录下;

2、将第一阶段通过Mybatis框架生成的model和dao复制到当前项目;----------------------------Dao层----------------------

3、搭建Service层:建com.softjx.service与com.softjx,service,impl包;----------------------------spring层----------------------

4、将需要相关的配置文件(mybatisconfig.xml,dbconfig.properties,applicationContext.xml,log4j.properties)放到src目录下;

  1)修改dbconfig.properties文件,ip,数据库,用户名,密码

  2)修改applicationContext.xml中的包名,目录名

5、在com.softjx.service包中写接口,在com.softjx.service.impl写接口的实现。
  注意:com.softjx.service.impl写接口的实现,
  @Service("studentService")
  @Transactional

  
  类中注入
  @Autowired
  private StudentMapper studentMapper;

7.单元测试:
  要注意mysql数据库中主键要自增,这一步要我们去mysql中设置。
  studentService = (StudentService) context.getBean("studentService");
  这个"studentService"是从@Service("studentService")

第三阶段:

1、修改WebRoot目录下的web.xml如下:

 <?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name> <!-- 配置启动 Spring IOC 容器的 Listener,启动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> <!-- 表单提交controller获得中文参数后乱码解决方案 注意: jsp页面编码设置为UTF-8 form表单提交方式为必须为post,get方式下面spring编码过滤器不起效果 --> <filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 可以把 POST 请求转为 DELETE 或 PUT 请求 --> <filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter> <filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 配置 DispatcherServlet -->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param>
<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>/</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

2、在src目录下建立springmvc.xml文件,文件内容如下:----------------------------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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 配置自定扫描的包 -->
<context:component-scan base-package="com.softjx" use-default-filters="false">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller"/>
</context:component-scan> <!-- 配置视图解析器: 如何把 handler 方法返回值解析为实际的物理视图 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean> <!-- 处理静态资源 -->
<mvc:default-servlet-handler/> <!-- 默认配置方案。
并提供了:数据绑定支持,@NumberFormatannotation支持,
@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),
读写JSON的支持(Jackson)。
后面,我们处理响应ajax请求时,就使用到了对json的支持。
-->
<mvc:annotation-driven></mvc:annotation-driven> </beans>

3、在src目录下新建com.softjx.action包,在包里建Action类;

注意:1)@Controller
   @RequestMapping("/student")

  2)每个方法:
   @RequestMapping("/studentAddInput")

  3) 类中注入
  @Autowired
  private StudentService studentService;//通过studentService调用Service里的方法调用Dao层

4、在WEB-INF目录下创建views文件,用来放置所有.jsp文件,这个jsp文件名是作为Action中方法 return的值。;

注意:1)在WEB-INF目录下的jsp页面只能通过程序来访问,外部访问不到。(安全)

    2)添加页面的jsp,要注意控件的属性名是javabean的属性名。 

SSM框架的搭建的更多相关文章

  1. ssm框架的搭建实现CRUD的操作

    最近在开发公司的一个系统,系统的框架是用ssm的框架搭建的,当然和这次写博客的不一样,它拥有很多的配置文件,企业级的开发所需要的配置文件是非常繁琐的,今天记录一下一个简单的SSM框架的搭建和实现一个C ...

  2. SSM框架手动搭建

    SSM框架手动搭建 创建web项目 IDEA创建Maven项目 [File]-->[new]-->[project..] 将项目变为web项目 [File]-->[Project S ...

  3. Spring+SpringMVC+Mybatis(SSM)框架集成搭建

    Spring+SpringMVC+Mybatis框架集成搭建教程 一.背景 最近有很多同学由于没有过SSM(Spring+SpringMvc+Mybatis , 以下简称SSM)框架的搭建的经历,所以 ...

  4. SSM框架整合搭建教程

    自己配置了一个SSM框架,打算做个小网站,这里把SSM的配置流程详细的写了出来,方便很少接触这个框架的朋友使用,文中各个资源均免费提供! 一. 创建web项目(eclipse) File-->n ...

  5. SSM框架——整合搭建流程

    1.首先创建maven工程,使用哪种方式进行创建都可以,可以参考博主之前的文章: <两种方式创建Maven项目[方式二]><两种方式创建Maven项目[方式一]> 2.先看看搭 ...

  6. SSM框架理解搭建(虽然是网上拼的,但是实际按照搭建是可以的)——

    SpringSpring就像是整个项目中装配bean的大工厂,在配置文件中可以指定使用特定的参数去调用实体类的构造方法来实例化对象.Spring的核心思想是IoC(控制反转),即不再需要程序员去显式地 ...

  7. SSM框架的搭建与测试

    关于框架的搭建无非就是 框架所依赖的jar包,然后就是关于各个框架的配置文件: 下面我们来看下不同层的依赖的jar包以及各个配置文件: 首先pojo这一层只需要依赖parent聚合工程 mapper层 ...

  8. ssm框架的搭建流程

    1.新建一个Maven project (1)选中create a simple project,自动配置必要的文件 (2)Packaging选择war类型.jar和war的区别就是一个是普通的jav ...

  9. Spring mybatis 之-ssm框架环境搭建(方案一)

    SSM框架- S-Spring  S-Spring mvc M-mybatis  就需要以下几个配置文件,放在resources文件夹下面: db.properties 放的是数据库连接池的配置文件, ...

随机推荐

  1. C setjmp和longjmp

    #include <stdio.h> #include <setjmp.h> void test(jmp_buf *env) { printf("setjmp tes ...

  2. 实验之-----------修改oracle实例名

    --查询当前数据库实例名称: SQL> select instance_name,status from v$instance; INSTANCE_NAME STATUS------------ ...

  3. Yii2之组件的注册与创建

    今天本来打算研究一下yii2.0的AR模型的实现原理,然而,计划赶不上变化,突然就想先研究一下yii2.0的数据库组件创建的过程.通过对yii源码的学习,了解了yii组件注册与创建的过程,并发现原来y ...

  4. LeetCode 121. Best Time to Buy and Sell Stock (买卖股票的最好时机)

    Say you have an array for which the ith element is the price of a given stock on day i. If you were ...

  5. Web性能测试工具之ab入门篇

    1. ab简介 ab全称Apache Bench,是apache附带的一个小工具,它可以同时模拟多个并发请求,测试apache等Web服务器的最大负载压力. 本文通过一个简单的示例,介绍了使用ab进行 ...

  6. .1-Vue源码起步

    搞事!搞事! 截止2017.5.16,终于把vue的源码全部抄完,总共有9624行,花时大概一个月时间,中间迭代了一个版本(2.2-2.3),部分代码可能不一致,不过没关系! 上一个链接https:/ ...

  7. struts2(一)之初识struts2

    前言 我们都知道struts2是一个框架,那什么是框架呢?很多人其实不太明白,其实框架就是一个半成品,别人将一些功能已经写好了,我们只需要拿来用即可,像我们之前 使用的dbutils框架,操作数据,只 ...

  8. Numpy数组索引为-1和None

    numpy的数组操作方便,可以用:来切片,用布尔数组或者布尔表达式来查找符合条件的数据,也可以用数组作为另一个数组的索引来查找指定的数据.但有时也会见到数组索引为-1和None.两者的用法如下: 1. ...

  9. 移动端二三事【三】:transform的注意事项

    1.js操作transition时需使用驼峰命名: div.style.WebkitTransform = div.style.transform = "rotate(90deg)" ...

  10. cocos-Lua中的class与require机制

    cocos-Lua中的class与require机制 local layer = require("PaiGow.src.GamePlayerListLayer")local Ga ...