天天看點

SSM整合SSM整合遇到的坑!!!

SSM整合遇到的坑!!!

1.建立maven-web項目

SSM整合SSM整合遇到的坑!!!

2. 配置Tomcat

添加artifacts

SSM整合SSM整合遇到的坑!!!
SSM整合SSM整合遇到的坑!!!

3. Idea web項目結構

idea建立web項目時可能不會建立java、resource目錄,自己補全,test目錄根據自己需求添加,target目錄啟動項目會自己生成,不用管

SSM整合SSM整合遇到的坑!!!

4.建立mapper映射檔案

SSM整合SSM整合遇到的坑!!!

報錯如下:

SSM整合SSM整合遇到的坑!!!

5. 關閉資料庫連結出現錯誤closing inbound before receiving peer’s close_notify

SSM整合SSM整合遇到的坑!!!

解決辦法:在url後加上useSSL=false

SSM整合SSM整合遇到的坑!!!

6.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>
   
</configuration>

           

7.Mybatis的mapper映射檔案頭檔案

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.mybatis.example.BlogMapper">
  <select id="selectBlog" resultType="Blog">
    select * from Blog where id = #{id}
  </select>
</mapper>
           

8. applicationContext中的aop、tx事務配置

SSM整合SSM整合遇到的坑!!!

否則報錯如下:Cannot locate BeanDefinitionDecorator for element [config]

SSM整合SSM整合遇到的坑!!!

9. web.xml配置檔案的頭檔案

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         id="WebApp_ID" version="3.0">
           

10. jsp頁面頭檔案

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
           

11. spring配置檔案頭檔案

<?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.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd">
       
           

12. 逆向工程xml配置檔案頭檔案

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
  PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
  "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
  
           

13. war包

SSM整合SSM整合遇到的坑!!!
SSM整合SSM整合遇到的坑!!!
SSM整合SSM整合遇到的坑!!!
SSM整合SSM整合遇到的坑!!!