博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring+SpringMVC+MyBatis的整合
阅读量:3942 次
发布时间:2019-05-24

本文共 5684 字,大约阅读时间需要 18 分钟。

Spring+SpringMVC+MyBatis的整合

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-FwPayGap-1601386537437)(https://i.loli.net/2020/06/10/soLQFY3PCXKz6Hy.png)]

1. 在pom.xml中导入所需依赖

junit
junit
4.11
test
org.springframework
spring-beans
5.2.5.RELEASE
org.springframework
spring-context-support
5.2.5.RELEASE
org.springframework
spring-webmvc
5.2.5.RELEASE
org.springframework
spring-jdbc
5.2.5.RELEASE
org.springframework
spring-tx
5.2.5.RELEASE
org.springframework
spring-test
5.2.5.RELEASE
com.github.pagehelper
pagehelper
5.1.8
org.mybatis
mybatis-spring
1.3.2
org.mybatis.generator
mybatis-generator-core
1.3.7
org.mybatis
mybatis
3.4.6
com.alibaba
druid
1.1.20
mysql
mysql-connector-java
5.1.30
javax.servlet
servlet-api
2.5
com.fasterxml.jackson.core
jackson-databind
2.9.9.3
commons-io
commons-io
2.6
commons-fileupload
commons-fileupload
1.4
org.slf4j
slf4j-simple
1.7.30

2. springMVC的配置

3. db.properties的配置

jdbc.driver=com.mysql.jdbc.Driverjdbc.jdbcUrl=jdbc:mysql://localhost:3306/数据库名称jdbc.username=rootjdbc.password=jdbc.maxActive=500jdbc.maxIdle=1000

4. applicationContext.xml的配置

5. mybatis-config.xml的配置

6. web.xml的配置

ssm-crud
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
contextConfigLocation
classpath:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
springDispatcherServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:springmvc.xml
1
springDispatcherServlet
/
CharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceRequestEncoding
true
forceResponseEncoding
true
CharacterEncodingFilter
/*

7. mbg.xml的配置

8. mbg.xml配置的使用,在test包下新建一个MBGTest类

package ssm.integration.test;import java.io.File;import java.util.ArrayList;import java.util.List;import org.mybatis.generator.api.MyBatisGenerator;import org.mybatis.generator.config.Configuration;import org.mybatis.generator.config.xml.ConfigurationParser;import org.mybatis.generator.internal.DefaultShellCallback;public class MBGTest {
public static void main(String[] args) throws Exception {
List
warnings = new ArrayList<>(); boolean overwrite = true; File configFile = new File("mbg.xml"); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(configFile); DefaultShellCallback callback = new DefaultShellCallback(overwrite); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); myBatisGenerator.generate(null); }}

转载地址:http://mziwi.baihongyu.com/

你可能感兴趣的文章
create symbolic array
查看>>
TAUCS库的编译(vs2010)
查看>>
color vector using in plotting example points and lines between corresponding vertices
查看>>
mex 里面调用matlab函数
查看>>
matlab中cuda编程中分配grid和block dimension的时候的注意事项
查看>>
GPU CUDA and MEX Programming
查看>>
arrayfun用法
查看>>
矩阵积分
查看>>
optimization on macOS
查看>>
Template-Based 3D Model Fitting Using Dual-Domain Relaxation
查看>>
install libfreenect2 on ubuntu 16.04
查看>>
how to use automake to build files
查看>>
using matlab drawing line graph for latex
查看>>
How package finding works
查看>>
build opencv3.3.0 with VTK8.0, CUDA9.0 on ubuntu9.0
查看>>
how to compile kinfu_remake with cuda 9.0 opencv2.4.13.4
查看>>
qtcreator4.4.1中cmake 与cmake3.5.1本身generate出来的setting是有区别的解决方法
查看>>
ubuntu下解决csdn网页打不开的问题
查看>>
MySQL server has gone away 问题的解决方法
查看>>
MySQL十大优化技巧
查看>>