一、springmvc---controller spring----service mybatiss---dao
pring(包括springmvc)、mybatis、mybatis-spring整合包、数据库驱动、第三方连接池。
因为springmvc和spring属于同一个公司不需要整合包,而mybaits和spring需要整合包。
二、jar包列表
pom文件依赖:
1 <dependencies> 2 <dependency> 3 <groupId>org.hamcrest</groupId> 4 <artifactId>hamcrest-library</artifactId> 5 <version>1.3</version> 6 </dependency> 7 <dependency> 8 <groupId>org.springframework</groupId> 9 <artifactId>spring-webmvc</artifactId> 10 <version>4.3.12.RELEASE</version> 11 </dependency> 12 <dependency> 13 <groupId>org.slf4j</groupId> 14 <artifactId>slf4j-log4j12</artifactId> 15 <version>1.7.5</version> 16 </dependency> 17 <dependency> 18 <groupId>org.slf4j</groupId> 19 <artifactId>slf4j-api</artifactId> 20 <version>1.7.5</version> 21 </dependency> 22 <dependency> 23 <groupId>org.apache.logging.log4j</groupId> 24 <artifactId>log4j-core</artifactId> 25 <version>2.0.2</version> 26 </dependency> 27 <dependency> 28 <groupId>org.apache.logging.log4j</groupId> 29 <artifactId>log4j-api</artifactId> 30 <version>2.0.2</version> 31 </dependency> 32 <dependency> 33 <groupId>spring-jms</groupId> 34 <artifactId>spring-jms</artifactId> 35 <version>4.2.4</version> 36 </dependency> 37 <dependency> 38 <groupId>org.springframework</groupId> 39 <artifactId>spring-web</artifactId> 40 <version>4.3.12.RELEASE</version> 41 </dependency> 42 <dependency> 43 <groupId>mysql</groupId> 44 <artifactId>mysql-connector-java</artifactId> 45 <version>5.1.34</version> 46 </dependency> 47 <dependency> 48 <groupId>taglibs-standard</groupId> 49 <artifactId>taglibs-standard</artifactId> 50 <version>1.2.5</version> 51 </dependency> 52 <dependency> 53 <groupId>taglibs-standard-spec</groupId> 54 <artifactId>taglibs-standard-spec</artifactId> 55 <version>1.2.5</version> 56 </dependency> 57 <dependency> 58 <groupId>org.springframework</groupId> 59 <artifactId>spring-oxm</artifactId> 60 <version>4.1.5.RELEASE</version> 61 </dependency> 62 <dependency> 63 <groupId>org.springframework</groupId> 64 <artifactId>spring-test</artifactId> 65 <version>4.3.12.RELEASE</version> 66 </dependency> 67 68 <dependency> 69 <groupId>org.springframework</groupId> 70 <artifactId>spring-expression</artifactId> 71 <version>4.3.12.RELEASE</version> 72 </dependency> 73 <dependency> 74 <groupId>org.springframework</groupId> 75 <artifactId>spring-core</artifactId> 76 <version>4.3.12.RELEASE</version> 77 </dependency> 78 <dependency> 79 <groupId>org.springframework</groupId> 80 <artifactId>spring-beans</artifactId> 81 <version>4.3.12.RELEASE</version> 82 </dependency> 83 <dependency> 84 <groupId>org.springframework</groupId> 85 <artifactId>spring-context</artifactId> 86 <version>4.3.12.RELEASE</version> 87 </dependency> 88 <dependency> 89 <groupId>org.springframework</groupId> 90 <artifactId>spring-context-support</artifactId> 91 <version>4.3.12.RELEASE</version> 92 </dependency> 93 <dependency> 94 <groupId>org.springframework</groupId> 95 <artifactId>spring-aop</artifactId> 96 <version>4.3.12.RELEASE</version> 97 </dependency> 98 <dependency> 99 <groupId>aopalliance</groupId> 100 <artifactId>aopalliance</artifactId> 101 <version>1.0</version> 102 </dependency> 103 <dependency> 104 <groupId>spring-aspects</groupId> 105 <artifactId>spring-aspects</artifactId> 106 <version>4.2.4</version> 107 </dependency> 108 <dependency> 109 <groupId>com.springsource.org</groupId> 110 <artifactId>aspectj.weaver</artifactId> 111 <version>1.6.8</version> 112 </dependency> 113 114 <dependency> 115 <groupId>org.apache.commons</groupId> 116 <artifactId>commons-pool2</artifactId> 117 <version>2.4.1</version> 118 </dependency> 119 120 <dependency> 121 <groupId>org.apache.commons</groupId> 122 <artifactId>commons-dbcp2</artifactId> 123 <version>2.0.1</version> 124 </dependency> 125 <dependency> 126 <groupId>org.springframework</groupId> 127 <artifactId>spring-jdbc</artifactId> 128 <version>4.1.5.RELEASE</version> 129 </dependency> 130 <dependency> 131 <groupId>log4j</groupId> 132 <artifactId>log4j</artifactId> 133 <version>1.2.17</version> 134 </dependency> 135 <dependency> 136 <groupId>org.javassist</groupId> 137 <artifactId>javassist</artifactId> 138 <version>3.16.1-GA</version> 139 </dependency> 140 <dependency> 141 <groupId>org.mybatis</groupId> 142 <artifactId>mybatis-spring</artifactId> 143 <version>1.2.2</version> 144 </dependency> 145 <dependency> 146 <groupId>org.springframework</groupId> 147 <artifactId>spring-tx</artifactId> 148 <version>4.1.5.RELEASE</version> 149 </dependency> 150 <dependency> 151 <groupId>commons-logging</groupId> 152 <artifactId>commons-logging</artifactId> 153 <version>1.1.1</version> 154 </dependency> 155 <dependency> 156 <groupId>cglib</groupId> 157 <artifactId>cglib</artifactId> 158 <version>2.2.2</version> 159 </dependency> 160 <dependency> 161 <groupId>asm</groupId> 162 <artifactId>asm</artifactId> 163 <version>3.3.1</version> 164 </dependency> 165 <dependency> 166 <groupId>org.mybatis</groupId> 167 <artifactId>mybatis</artifactId> 168 <version>3.2.7</version> 169 </dependency> 170 <dependency> 171 <groupId>junit</groupId> 172 <artifactId>junit</artifactId> 173 <version>4.11</version> 174 <scope>test</scope> 175 </dependency> 176 <dependency> 177 <groupId>org.junit.jupiter</groupId> 178 <artifactId>junit-jupiter-api</artifactId> 179 <version>RELEASE</version> 180 </dependency> 181 <dependency> 182 <groupId>org.springframework</groupId> 183 <artifactId>spring-test</artifactId> 184 <version>4.3.12.RELEASE</version> 185 </dependency>
三、配置文件
1、SqlMapConfig.xml: mybaits配置文件,只保存约束和configuration标签即可,其中的mapper映射在applicationContex-dao.xml里进行添加。
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE configuration 3 PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 4 "http://mybatis.org/dtd/mybatis-3-config.dtd"> 5 6 7 <configuration> 8 </configuration>
2、applicationContext-dao.xml:dao层配置文件
1)数据库连接池
2)会话工厂
3)配置mapper扫描
3、service层
1)applicationContext-service.xml 包扫描器和Service层的注解开启。
2)applicationContext-trans.xml事务配置文件。
4、Springmvc.xml
1)注解扫描器开启
2)注解驱动(处理器映射器和处理器适配器)
3)视图解析器配置
5、web.xml 前端控制器配置。
原文地址:https://www.cnblogs.com/evilliu/p/8974125.html
时间: 2024-10-08 21:14:54