3、spring+mybatis关联映射(无mapper实现类)+idea+maven
该工程采用spring+mybatis的关联映射,动态sql,sql片段实现
1、搭建项目结构如下
2、配置项目的pom.xml文件中的依赖
1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <modelVersion>4.0.0</modelVersion> 6 7 <groupId>com</groupId> 8 <artifactId>springmybatis_day44_03</artifactId> 9 <version>1.0-SNAPSHOT</version> 10 <packaging>war</packaging> 11 12 <name>springmybatis_day44_03 Maven Webapp</name> 13 <!-- FIXME change it to the project"s website --> 14 <url>http://www.example.com</url> 15 16 <properties> 17 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 18 <maven.compiler.source>1.7</maven.compiler.source> 19 <maven.compiler.target>1.7</maven.compiler.target> 20 </properties> 21 22 23 <dependencies> 24 25 <dependency> 26 <groupId>junit</groupId> 27 <artifactId>junit</artifactId> 28 <version>4.11</version> 29 </dependency> 30 31 <!--1 https://mvnrepository.com/artifact/org.springframework/spring-beans --> 32 <dependency> 33 <groupId>org.springframework</groupId> 34 <artifactId>spring-beans</artifactId> 35 <version>4.3.6.RELEASE</version> 36 </dependency> 37 38 39 <!--2 https://mvnrepository.com/artifact/org.springframework/spring-context --> 40 <dependency> 41 <groupId>org.springframework</groupId> 42 <artifactId>spring-context</artifactId> 43 <version>4.3.6.RELEASE</version> 44 </dependency> 45 46 47 <!-- 3https://mvnrepository.com/artifact/org.springframework/spring-core --> 48 <dependency> 49 <groupId>org.springframework</groupId> 50 <artifactId>spring-core</artifactId> 51 <version>4.3.6.RELEASE</version> 52 </dependency> 53 54 55 <!--4 https://mvnrepository.com/artifact/org.springframework/spring-expression --> 56 <dependency> 57 <groupId>org.springframework</groupId> 58 <artifactId>spring-expression</artifactId> 59 <version>4.3.6.RELEASE</version> 60 </dependency> 61 62 63 <!--5 https://mvnrepository.com/artifact/org.springframework/spring-aop --> 64 <dependency> 65 <groupId>org.springframework</groupId> 66 <artifactId>spring-aop</artifactId> 67 <version>4.3.6.RELEASE</version> 68 </dependency> 69 70 71 <!--6 https://mvnrepository.com/artifact/aopalliance/aopalliance --> 72 <dependency> 73 <groupId>aopalliance</groupId> 74 <artifactId>aopalliance</artifactId> 75 <version>1.0</version> 76 </dependency> 77 78 79 <!--7 https://mvnrepository.com/artifact/org.aspectj/aspectjweaver --> 80 <dependency> 81 <groupId>org.aspectj</groupId> 82 <artifactId>aspectjweaver</artifactId> 83 <version>1.8.10</version> 84 </dependency> 85 86 87 <!--8 https://mvnrepository.com/artifact/log4j/log4j --> 88 <dependency> 89 <groupId>log4j</groupId> 90 <artifactId>log4j</artifactId> 91 <version>1.2.17</version> 92 </dependency> 93 94 95 <!--9 https://mvnrepository.com/artifact/commons-logging/commons-logging --> 96 <dependency> 97 <groupId>commons-logging</groupId> 98 <artifactId>commons-logging</artifactId> 99 <version>1.2</version> 100 </dependency> 101 102 103 <!--10 https://mvnrepository.com/artifact/org.springframework/spring-jdbc --> 104 <dependency> 105 <groupId>org.springframework</groupId> 106 <artifactId>spring-jdbc</artifactId> 107 <version>4.3.6.RELEASE</version> 108 </dependency> 109 110 111 <!--11 https://mvnrepository.com/artifact/org.springframework/spring-orm --> 112 <dependency> 113 <groupId>org.springframework</groupId> 114 <artifactId>spring-orm</artifactId> 115 <version>4.3.6.RELEASE</version> 116 </dependency> 117 118 119 <!--12 https://mvnrepository.com/artifact/org.springframework/spring-tx --> 120 <dependency> 121 <groupId>org.springframework</groupId> 122 <artifactId>spring-tx</artifactId> 123 <version>4.3.6.RELEASE</version> 124 </dependency> 125 126 127 <!--13 https://mvnrepository.com/artifact/org.springframework/spring-web --> 128 <dependency> 129 <groupId>org.springframework</groupId> 130 <artifactId>spring-web</artifactId> 131 <version>4.3.6.RELEASE</version> 132 </dependency> 133 134 135 <!--14 https://mvnrepository.com/artifact/org.springframework/spring-webmvc --> 136 <dependency> 137 <groupId>org.springframework</groupId> 138 <artifactId>spring-webmvc</artifactId> 139 <version>4.3.6.RELEASE</version> 140 </dependency> 141 142 143 <!--15 https://mvnrepository.com/artifact/org.mybatis/mybatis --> 144 <dependency> 145 <groupId>org.mybatis</groupId> 146 <artifactId>mybatis</artifactId> 147 <version>3.4.6</version> 148 </dependency> 149 150 <!--17 https://mvnrepository.com/artifact/org.mybatis/mybatis-spring --> 151 <dependency> 152 <groupId>org.mybatis</groupId> 153 <artifactId>mybatis-spring</artifactId> 154 <version>1.3.2</version> 155 </dependency> 156 157 158 <!--16 https://mvnrepository.com/artifact/mysql/mysql-connector-java --> 159 <dependency> 160 <groupId>mysql</groupId> 161 <artifactId>mysql-connector-java</artifactId> 162 <version>5.1.38</version> 163 </dependency> 164 165 166 <!--18 https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --> 167 <dependency> 168 <groupId>javax.servlet</groupId> 169 <artifactId>javax.servlet-api</artifactId> 170 <version>3.1.0</version> 171 </dependency> 172 173 <!--19 https://mvnrepository.com/artifact/javax.servlet/jstl --> 174 <dependency> 175 <groupId>javax.servlet</groupId> 176 <artifactId>jstl</artifactId> 177 <version>1.2</version> 178 </dependency> 179 180 181 <!--20 https://mvnrepository.com/artifact/taglibs/standard --> 182 <dependency> 183 <groupId>taglibs</groupId> 184 <artifactId>standard</artifactId> 185 <version>1.1.2</version> 186 </dependency> 187 188 </dependencies> 189 190 </project>