博客
关于我
IDEA下java的SSM框架搭建
阅读量:622 次
发布时间:2019-03-13

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

SSM(Spring + Spring MVC + MyBatis)框架的搭建是一个涉及多个配置步骤和知识的过程。以下将从项目初始化、依赖项管理、数据库配置、框架组件配置以及应用开发等方面详细介绍SSM框架的搭建过程。

1. 项目初始化

首先,打开Idea IDE,创建一个新的Maven项目。在项目_inicio.xml_中,添加所需的依赖项和插件。例如:

4.0.0
com.htt
htt
1.0-SNAPSHOT
< packaging>war
http://mav.apache.org
4.0.2.RELEASE
3.2.6
1.7.7
1.2.17
0.9.5-pre8

在项目初始化完成后,使用Maven Keyboard插件或在终端使用命令安装所有依赖项。

2. 数据库配置

jdbc.properties文件中,配置数据库连接信息:

jdbc.driver=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost:3306/ChatRobot?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=falsejdbc.username=rootjdbc.password=mysqlc3p0.maxPoolSize=30c3p0.minPoolSize=10c3p0.autoCommitOnClose=falsec3p0.checkoutTimeout=10000c3p0.acquireRetryAttempts=2

3. 依赖项配置

pom.xml中添加所有必要的依赖项。例如:

org.springframework
spring-core
${spring.version}
org.springframework
spring-web
${spring.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
com.mchange
c3p0
0.9.5-pre8
junit
junit
4.11
test
com.slf4j
slf4j-api
${slf4j.version}
com.slf4j
slf4j-log4j12
${slf4j.version}

4. 框架配置

通过配置文件实现Spring MVC和MyBatis的集成。

4.1. 数据库连接池配置

spring-mybatis.xml中配置数据库连接池:

4.2. 模型配置

mybatis-mapper.xml中定义数据库映射。例如:

INSERT INTO user(username, password, HeadImage) VALUES (#{username}, #{password}, #{HeadImage})

5. 项目部署

在local环境中,使用Lighttpd服务器进行项目部署。通过mavencargo插件或手动部署将项目打包并上传到服务器。

5. 测试

使用postman等工具,进行功能测试,确保各项API均正常响应。同时,检查数据库连接池的性能和事务管理是否正确。

6.Remarks

通过以上步骤,你完成了SSM框架的完整搭建,能够支持用户的注册、登录、信息查询和其他业务功能。随着项目的复杂化,可能需要增加更多的配置和依赖项,但基本的架构已经完善,为后续开发奠定了基础。

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

你可能感兴趣的文章
npm error Missing script: “server“npm errornpm error Did you mean this?npm error npm run serve
查看>>
npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
查看>>
npm install CERT_HAS_EXPIRED解决方法
查看>>
npm install digital envelope routines::unsupported解决方法
查看>>
npm install 卡着不动的解决方法
查看>>
npm install 报错 EEXIST File exists 的解决方法
查看>>
npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
查看>>
npm install 报错 Failed to connect to github.com port 443 的解决方法
查看>>
npm install 报错 fatal: unable to connect to github.com 的解决方法
查看>>
npm install 报错 no such file or directory 的解决方法
查看>>
npm install 权限问题
查看>>
npm install报错,证书验证失败unable to get local issuer certificate
查看>>
npm install无法生成node_modules的解决方法
查看>>
npm install的--save和--save-dev使用说明
查看>>
npm node pm2相关问题
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm run build报Cannot find module错误的解决方法
查看>>
npm run build部署到云服务器中的Nginx(图文配置)
查看>>
npm run dev 和npm dev、npm run start和npm start、npm run serve和npm serve等的区别
查看>>
npm run dev 报错PS ‘vite‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
查看>>