详解手把手Maven搭建SpringMVC+Spring+MyBatis框架(超级详细版)
转载(https://www.jb51.net/article/130560.htm)
SSM(Spring+SpringMVC+Mybatis),目前较为主流的企业级架构方案。标准的MVC设计模式,将整个系统划分为显示层、Controller层、Service层、Dao层四层,使用SpringMVC负责请求的转发和视图管理,Spring实现业务对象管理, MyBatis作为数据对象持久化引擎。
一. 框架详情
Spring是一个轻量级的Java开发框架,它是为了解决企业应用开发的复杂性而创建的。Spring的用途不仅限于服务器端的开发。从简单性、可测试性和松耦合的角度而言,任何Java应用都可以从Spring中受益。 简单来说,Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架
SpringMVC属于SpringFrameWork的后续产品,分离了控制器、模型对象、分派器以及处理程序对象的角色,这种分离让它们更容易进行定制
MyBatis是一个基于Java的持久层框架。MyBatis提供的持久层框架包括SQL Maps和Data Access Objects(DAO)它消除了几乎所有的JDBC代码和参数的手工设置以及结果集的检索。MyBatis 使用简单的 XML或注解用于配置和原始映射,将接口和 Java映射成数据库中的记录
二. 创建Maven项目
1、Eclipse中用Maven创建项目
2、按默认Next
3、找到maven-archetype-webapp后,点击next
4、填写相应的信息,GroupID是项目组织唯一的标识符,实际对应JAVA的包的结构。ArtifactID就是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称。Package填了默认给你建一个包,不写也可以。
5、刚建好的目录如下
6、Maven规定必须添加以下Source Folder:
src/main/resources
src/main/java
src/test/resources
src/test/java
在这步之前最好先项目上右键选择properties,然后点击java build path,在Librarys下,编辑JRE System Library,选择workspace default jre。
7、分别修改输出路径为,对应关系如下:
8、将项目转换成Dynamic Web Project,在项目上右键Properties,在左侧选择 Project Facets。
9、设置部署时的文件发布路径,删除test的两项,因为test是测试使用,并不需要部署。
设置将Maven的jar包发布到lib下。Add -> Java Build Path Entries -> Maven Dependencies -> Finish
三. Maven引入需要的JAR包
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
< project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" < modelVersion >4.0.0</ modelVersion > < groupId >com.yingjun.test</ groupId > < artifactId >TradingState</ artifactId > < packaging >war</ packaging > < version >2.0.1</ version > < properties > < project.build.sourceEncoding >UTF-8</ project.build.sourceEncoding > < maven.build.timestamp.format >yyyyMMddHHmmss</ maven.build.timestamp.format > < spring.version >3.2.9.RELEASE</ spring.version > < mybatis.version >3.1.1</ mybatis.version > < mybatisspring.version >1.1.1</ mybatisspring.version > </ properties > < dependencies > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-core</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-webmvc</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-test</ artifactId > < version >${spring.version}</ version > </ dependency > < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis</ artifactId > < version >${mybatis.version}</ version > </ dependency > < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis-spring</ artifactId > < version >${mybatisspring.version}</ version > </ dependency > < dependency > < groupId >mysql</ groupId > < artifactId >mysql-connector-java</ artifactId > < version >5.1.34</ version > </ dependency > < dependency > < groupId >junit</ groupId > < artifactId >junit</ artifactId > < version >4.11</ version > < scope >test</ scope > </ dependency > < dependency > < groupId >c3p0</ groupId > < artifactId >c3p0</ artifactId > < version >0.9.1.2</ version > </ dependency > < dependency > < groupId >org.aspectj</ groupId > < artifactId >aspectjweaver</ artifactId > < version >1.8.1</ version > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >jstl</ artifactId > < version >1.2</ version > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >servlet-api</ artifactId > < version >3.0</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.servlet.jsp</ groupId > < artifactId >jsp-api</ artifactId > < version >2.2</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >commons-fileupload</ groupId > < artifactId >commons-fileupload</ artifactId > < version >1.3.1</ version > </ dependency > < dependency > < groupId >commons-lang</ groupId > < artifactId >commons-lang</ artifactId > < version >2.6</ version > </ dependency > < dependency > < groupId >commons-codec</ groupId > < artifactId >commons-codec</ artifactId > < version >1.9</ version > </ dependency > < dependency > < groupId >org.apache.httpcomponents</ groupId > < artifactId >httpclient</ artifactId > < version >4.5</ version > </ dependency > < dependency > < groupId >org.slf4j</ groupId > < artifactId >slf4j-api</ artifactId > < version >1.7.10</ version > </ dependency > < dependency > < groupId >org.slf4j</ groupId > < artifactId >slf4j-log4j12</ artifactId > < version >1.7.10</ version > </ dependency > < dependency > < groupId >log4j</ groupId > < artifactId >log4j</ artifactId > < version >1.2.17</ version > </ dependency > < dependency > < groupId >com.alibaba</ groupId > < artifactId >fastjson</ artifactId > < version >1.1.41</ version > </ dependency > < dependency > < groupId >org.codehaus.jackson</ groupId > < artifactId >jackson-mapper-asl</ artifactId > < version >1.9.13</ version > </ dependency > </ dependencies > < build > < plugins > < plugin > < artifactId >maven-compiler-plugin</ artifactId > < version >2.3.2</ version > < configuration > < source >1.7</ source > < target >1.7</ target > </ configuration > </ plugin > < plugin > < artifactId >maven-war-plugin</ artifactId > < version >2.2</ version > < configuration > < version >3.0</ version > < failOnMissingWebXml >false</ failOnMissingWebXml > </ configuration > </ plugin > </ plugins > < finalName >${project.artifactId}_${project.version}_${maven.build.timestamp}</ finalName > </ build > </ project > |
四. 相关配置文件配置,整合SSM框架
web.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<? xml version = "1.0" encoding = "UTF-8" ?> xsi:schemaLocation = "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version = "2.4" > <!-- 配置 Spring --> < context-param > < param-name >contextConfigLocation</ param-name > < param-value >classpath:spring.xml</ param-value > </ context-param > < listener > < listener-class >org.springframework.web.context.ContextLoaderListener</ listener-class > </ listener > <!-- 防止Spring内存溢出监听器 --> < listener > < listener-class >org.springframework.web.util.IntrospectorCleanupListener</ listener-class > </ listener > <!-- 配置springmvc --> < servlet > < servlet-name >springMVC</ servlet-name > < servlet-class >org.springframework.web.servlet.DispatcherServlet</ servlet-class > < init-param > < param-name >contextConfigLocation</ param-name > < param-value >classpath:spring-mvc.xml</ param-value > </ init-param > < load-on-startup >1</ load-on-startup > </ servlet > < servlet-mapping > < servlet-name >springMVC</ servlet-name > < url-pattern >/</ url-pattern > </ servlet-mapping > <!-- 字符集过滤器 --> < filter > < filter-name >encodingFilter</ 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 >encodingFilter</ filter-name > < url-pattern >/*</ url-pattern > </ filter-mapping > </ web-app > |
spring.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<? xml version = "1.0" encoding = "UTF-8" ?> xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc = "http://www.springframework.org/schema/mvc" xmlns:aop = "http://www.springframework.org/schema/aop" xmlns:tx = "http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans <!-- 扫描service、dao组件 --> < context:component-scan base-package = "com.yingjun.test" /> <!-- 分解配置 jdbc.properites --> < context:property-placeholder location = "classpath:jdbc.properties" /> <!-- 数据源c3p0 --> < bean id = "dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" > < property name = "driverClass" value = "${jdbc.driverClassName}" /> < property name = "jdbcUrl" value = "${jdbc.url}" /> < property name = "user" value = "${jdbc.username}" /> < property name = "password" value = "${jdbc.password}" /> < property name = "maxPoolSize" value = "${c3p0.pool.size.max}" /> < property name = "minPoolSize" value = "${c3p0.pool.size.min}" /> < property name = "initialPoolSize" value = "${c3p0.pool.size.ini}" /> < property name = "acquireIncrement" value = "${c3p0.pool.size.increment}" /> </ bean > <!-- sessionFactory 将spring和mybatis整合 --> < bean id = "sqlSessionFactory" class = "org.mybatis.spring.SqlSessionFactoryBean" > < property name = "dataSource" ref = "dataSource" /> < property name = "configLocation" value = "classpath:spring-mybatis.xml" /> < property name = "mapperLocations" value = "classpath*:com/yingjun/test/mapping/**/*.xml" /> </ bean > < bean class = "org.mybatis.spring.mapper.MapperScannerConfigurer" > < property name = "basePackage" value = "com,yingjun.test.dao" /> < property name = "sqlSessionFactoryBeanName" value = "sqlSessionFactory" /> </ bean > < bean id = "transactionManager" class = "org.springframework.jdbc.datasource.DataSourceTransactionManager" > < property name = "dataSource" ref = "dataSource" /> </ bean > < tx:advice id = "transactionAdvice" transaction-manager = "transactionManager" > < tx:attributes > < tx:method name = "add*" propagation = "REQUIRED" /> < tx:method name = "append*" propagation = "REQUIRED" /> < tx:method name = "insert*" propagation = "REQUIRED" /> < tx:method name = "save*" propagation = "REQUIRED" /> < tx:method name = "update*" propagation = "REQUIRED" /> < tx:method name = "modify*" propagation = "REQUIRED" /> < tx:method name = "edit*" propagation = "REQUIRED" /> < tx:method name = "delete*" propagation = "REQUIRED" /> < tx:method name = "remove*" propagation = "REQUIRED" /> < tx:method name = "repair" propagation = "REQUIRED" /> < tx:method name = "delAndRepair" propagation = "REQUIRED" /> < tx:method name = "get*" propagation = "SUPPORTS" /> < tx:method name = "find*" propagation = "SUPPORTS" /> < tx:method name = "load*" propagation = "SUPPORTS" /> < tx:method name = "search*" propagation = "SUPPORTS" /> < tx:method name = "datagrid*" propagation = "SUPPORTS" /> < tx:method name = "*" propagation = "SUPPORTS" /> </ tx:attributes > </ tx:advice > < aop:config > < aop:pointcut id = "transactionPointcut" expression = "execution(* com.yingjun.test.service..*Impl.*(..))" /> < aop:advisor pointcut-ref = "transactionPointcut" advice-ref = "transactionAdvice" /> </ aop:config > </ beans > |
为了代替手工使用 SqlSessionDaoSupport 或 SqlSessionTemplate 编写数据访问对象 (DAO)的代码,MyBatis-Spring 提供了一个动态代理的实现:MapperFactoryBean。这个类 可以让你直接注入数据映射器接口到你的 service 层 bean 中。当使用映射器时,你仅仅如调 用你的 DAO 一样调用它们就可以了,但是你不需要编写任何 DAO 实现的代码,因为 MyBatis-Spring 将会为你创建代理。
spring-mybatis.xml
1
2
3
4
5
|
<? 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 > |
spring-mvc.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<? xml version = "1.0" encoding = "UTF-8" ?> xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:p = "http://www.springframework.org/schema/p" xsi:schemaLocation=" <!-- 默认的注解映射的支持 --> < mvc:annotation-driven /> <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> < context:component-scan base-package = "com.yingjun.test.controller" /> <!--避免IE执行AJAX时,返回JSON出现下载文件 --> < bean id = "mappingJacksonHttpMessageConverter" class = "org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" > < property name = "supportedMediaTypes" > < list > < value >text/html;charset=UTF-8</ value > </ list > </ property > </ bean > <!-- 定义跳转的文件的前后缀 ,视图模式配置 --> < bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver" > <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 --> < property name = "prefix" value = "/WEB-INF/jsp/" /> < property name = "suffix" value = ".jsp" /> </ bean > <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --> < bean id = "multipartResolver" class = "org.springframework.web.multipart.commons.CommonsMultipartResolver" > <!-- 默认编码 --> < property name = "defaultEncoding" value = "utf-8" /> <!-- 文件大小最大值 --> < property name = "maxUploadSize" value = "10485760000" /> <!-- 内存中的最大值 --> < property name = "maxInMemorySize" value = "40960" /> </ bean > </ beans > |
log4j.properties
1
2
3
4
5
6
7
8
9
|
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.username=root jdbc.password=root c3p0.pool.size.max=20 c3p0.pool.size.min=5 c3p0.pool.size.ini=3 c3p0.pool.size.increment=2 |
jdbc.properties
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
log4j.rootLogger=info, console, debug, app, error ###Console ### log4j.appender.console = org.apache.log4j.ConsoleAppender log4j.appender.console.Target = System.out log4j.appender.console.layout = org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern = %d %p[%C:%L]- %m%n ### debug ### log4j.appender.debug = org.apache.log4j.DailyRollingFileAppender log4j.appender.debug.File = log/debug.log log4j.appender.debug.Append = true log4j.appender.debug.Threshold = DEBUG log4j.appender.debug.DatePattern='.'yyyy-MM-dd log4j.appender.debug.layout = org.apache.log4j.PatternLayout log4j.appender.debug.layout.ConversionPattern = %d %p[%c:%L] - %m%n ### app ### log4j.appender.app = org.apache.log4j.DailyRollingFileAppender log4j.appender.app.File = log/app.log log4j.appender.app.Append = true log4j.appender.app.Threshold = INFO log4j.appender.app.DatePattern='.'yyyy-MM-dd log4j.appender.app.layout = org.apache.log4j.PatternLayout log4j.appender.app.layout.ConversionPattern = %d %p[%c:%L] - %m%n ### Error ### log4j.appender.error = org.apache.log4j.DailyRollingFileAppender log4j.appender.error.File = log/error.log log4j.appender.error.Append = true log4j.appender.error.Threshold = ERROR log4j.appender.error.DatePattern='.'yyyy-MM-dd log4j.appender.error.layout = org.apache.log4j.PatternLayout log4j.appender.error.layout.ConversionPattern =%d %p[%c:%L] - %m%n |
五. 利用MyBatis Generator自动创建实体类、映射文件以及DAO接口
MyBatis属于一种半自动的ORM框架,所以主要的工作就是配置Mapping映射文件,但是由于手写映射文件很容易出错,所以可利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件。这样可以省去很多的功夫,将生成的代码copy到项目工程中即可。
生成代码需要的文件和jar并建立如下目录结构:
在generatorl.xml中配置相关的数据库连接,已经数据库表:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<? xml version = "1.0" encoding = "UTF-8" ?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" < generatorConfiguration > <!-- 数据库驱动 --> < classPathEntry location = "mysql-connector-java-5.1.34.jar" /> < context id = "DB2Tables" targetRuntime = "MyBatis3" > < commentGenerator > < property name = "suppressDate" value = "true" /> <!-- 是否去除自动生成的注释 true:是 : false:否 --> < property name = "suppressAllComments" value = "true" /> </ commentGenerator > <!--数据库链接URL,用户名、密码 --> < jdbcConnection driverClass = "com.mysql.jdbc.Driver" userId = "root" password = "root" > </ jdbcConnection > < javaTypeResolver > < property name = "forceBigDecimals" value = "false" /> </ javaTypeResolver > <!-- 生成模型的包名和位置 --> < javaModelGenerator targetPackage = "com.yingjun.test.model" targetProject = "src" > < property name = "enableSubPackages" value = "true" /> < property name = "trimStrings" value = "true" /> </ javaModelGenerator > <!-- 生成映射文件的包名和位置 --> < sqlMapGenerator targetPackage = "com.yingjun.test.mapping" targetProject = "src" > < property name = "enableSubPackages" value = "true" /> </ sqlMapGenerator > <!-- 生成DAO的包名和位置 --> < javaClientGenerator type = "XMLMAPPER" targetPackage = "com.yingjun.test.dao" targetProject = "src" > < property name = "enableSubPackages" value = "true" /> </ javaClientGenerator > <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名 --> < table tableName = "other_list" domainObjectName = "OtherList" enableCountByExample = "fasle" enableUpdateByExample = "false" enableDeleteByExample = "false" enableSelectByExample = "false" selectByExampleQueryId = "false" > </ table > </ context > </ generatorConfiguration > |
打开CMD窗口 进入该目录结构,输入命令行:
java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite
运行完成后会生成相应的dao mapper 和model,是不是很爽。
六. 建立Service层以及conrorller层
1
2
3
4
5
|
package com.yingjun.test.service; public interface OtherServiceI { public String getOterList(); } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package com.yingjun.test.service; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.yingjun.test.dao.OtherListMapper; import com.yingjun.test.model.OtherList; import com.yingjun.test.model.OtherListDomain; @Service public class OtherServiceImpl implements OtherServiceI { @Autowired private OtherListMapper otherListMapper; @Override public String getOterList() { Set<String> set= new HashSet<String>(); List<OtherList> list=otherListMapper.selectAll(); List<OtherListDomain> jsonList= new ArrayList<OtherListDomain>(); for (OtherList other:list){ String title=other.getTitle(); if (set.contains(title)){ continue ; } else { List<OtherList> t_list= new ArrayList<OtherList>(); for (OtherList data:list){ if (title.equals(data.getTitle())){ t_list.add(data); } } OtherListDomain domain= new OtherListDomain(); domain.setTitle(title); domain.setItems(t_list); jsonList.add(domain); set.add(other.getTitle()); } } return JSON.toJSONString(jsonList, SerializerFeature.WriteMapNullValue); } } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package com.yingjun.test.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.alibaba.fastjson.JSON; import com.yingjun.test.service.OtherServiceI; import com.yingjun.test.service.StockStatusServiceI; @Controller @RequestMapping (value = "/" ) public class TSSController { @Autowired private OtherServiceI otherService; @RequestMapping (value= "/getOtherList" ,produces= "text/html;charset=UTF-8" ) @ResponseBody private String getOtherList(){ String json=otherService.getOterList(); return json; } } |
七. 建立测试类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import java.util.List; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith (SpringJUnit4ClassRunner. class ) @ContextConfiguration (locations = { "classpath:spring.xml" }) public class TestMybatis { @Autowired private OtherServiceI service; @Test public void test() { String list=service.getOterList(); logger.info(list); } } |
八. 通过浏览器进行验证
http://localhost:8080/TzyjStateService/getOtherList
至此,测试成功,SSM三大框架的整合就完成了,有什么其他需求可以在此基础继续添
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
详解手把手Maven搭建SpringMVC+Spring+MyBatis框架(超级详细版)的更多相关文章
- 手把手Maven搭建SpringMVC+Spring+MyBatis框架(超级详细版)
手把手Maven搭建SpringMVC+Spring+MyBatis框架(超级详细版) SSM(Spring+SpringMVC+Mybatis),目前较为主流的企业级架构方案.标准的MVC设计模式, ...
- Maven 搭建SpringMvc+Spring+Mybatis详细记录
总觉得,看比人写的总是那么好,每次搭建框架时都会找博客,找教程来跟着一步一步走,虽然很快搭建成功了,但是经常情况是我并不知道我干了什么,也不记得具体步骤,到底为什么要这么做,今天我详细记录了一下自己搭 ...
- SSM框架-----------SpringMVC+Spring+Mybatis框架整合详细教程
1.基本概念 1.1.Spring Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-One ...
- eclipse + maven 搭建springMVC+Spring+mybatis 系统
首先需要下载maven 安装maven插件.自行百度. 1: 创建maven系统 http://huxiaoheihei.iteye.com/blog/1766986 2:添加pom依赖: pom.x ...
- 单工程搭建springmvc+spring+mybatis(maven,idea)
单工程搭建springmvc+spring+mybatis(maven,idea) 1.pom.xml <properties> <project.build.sourceEncod ...
- struts2 + spring + mybatis 框架整合详细介绍
struts2 + spring + mybatis 框架整合详细介绍 参考地址: https://blog.csdn.net/qq_22028771/article/details/5149898 ...
- Maven搭建springMVC+spring+hibernate环境
这次不再使用struts2做控制器,采用spring自己的springMVC框架实现. 首先,改写pom.xml文件,不需要struts2的相关jar了. pom.xml <project xm ...
- SpringMVC+Spring+Mybatis框架集成
一.基本概念 1.Spring Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-O ...
- SSM(SpringMVC Spring Mybatis)框架整合搭建
1.新建一个web工程. 2.首先看一下整体的框架结构: 3.将ssm框架搭建所需要的jar包复制到lib目录下 3.需要配置各个配置文件. 1)配置web.xml文件: <?xml versi ...
随机推荐
- zbar android sdk在CentOS 7下的编译和使用
环境:CentOS 7+NDK 20.0.5594570+libiconv-1.14 下载 下载libiconv-1.14版本,地址: https://ftp.gnu.org/pub/gnu/libi ...
- R数据挖掘 第一篇:聚类分析(划分)
聚类是把一个数据集划分成多个子集的过程,每一个子集称作一个簇(Cluster),聚类使得簇内的对象具有很高的相似性,但与其他簇中的对象很不相似,由聚类分析产生的簇的集合称作一个聚类.在相同的数据集上, ...
- Python程序调试工具Py-Spy
序言 如果你是从Java语言开发转Python开发,可能在庆幸自己的开发效率提高了很多,但是也有痛苦的时候,比如你会怀念jstack,jmap, 等各种工具在生产环境做perfomance tunin ...
- 使用Visual Studio的单元测试
步骤1:创建被测试项目 创建单元测试项目步骤2:在测试项目中写测试代码步骤3:运行测试 方法1 右键运行测试,方法2 点击测试 运行所有测试备注:单击方法 右测有提示可以看测试方法的输出
- python 排序 选择排序
算法思想: 首先从序列中选择一个最值,将这个元素和序列的首地址上的元素交换,这样就完成了一个元素的排序,接下来,重复上述过程,不断的从剩下的序列中选取最值,然后添加到有序部分的末尾(注意,这种添加是通 ...
- Qt QVector简单用法
添加元素 QVector<QString> strArray; strArray.append("Hello"); 遍历 QVector<QString>: ...
- Es6学习指南-1-函数变量
本篇章我们简述的是 es6初级知识点,认识es6,以及es6变量和es5的变量和函数. ECMAScript 6简介 ECMAScript 6.0(以下简称ES6)是JavaScript语言的下一代 ...
- day 45
目录 form表单(**************) 参数 action method select标签 下拉框 textarea标签 CSS 注释 css的语法结构 css的三种引入方式 css查找( ...
- MySQL基础:DCL语句总结
SQL语言大致分为DCL.DDL.DML三种,本文主要介绍MySQL 5.7版本DCL语句. 概述 DCL(Data Control Language)语句:数据控制语句,用于控制不同数据段直接的许可 ...
- Semaphore的简介及应用场景
Semaphore是一个计数信号量,常用于限制可以访问某些资源(物理或逻辑的)线程数目. 常用函数: 信号量的构造函数 非公平: public Semaphore(int permits);//per ...