博客
关于我
手把手教你使用SSM框架实现一个学生管理系统第二章之创建一个web工程及相关配置文件的介绍
阅读量:451 次
发布时间:2019-03-06

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

SSM框架的基本介绍

文字概述:

SSM:spring+springMVC+mybaits

Spring:是一个容器,就是一个bean(实体对象)大集合。
SpringMVC:控制器(业务逻辑层)(视图分发器)。
Mybaits:jdbc的封装(数据库框架)Mapper.xml。

三大框架各司其职:

使用spring MVC负责请求的转发和视图管理

spring实现业务对象管理
mybatis作为数据对象的持久化引擎

流程图解:

创建一个web项目

1.在IDEA的工作目录下新建一个文件夹

2.在IDEA中打开这一文件夹

3.选中文件夹右键点击New ->Module

4.之间点击Next

5.输入对应的文件名及其路径

6.成功创建

![image.png]([object Object]&name=image.png&originHeight=697&originWidth=1011&size=98141&status=done&style=none&width=505.5)

7.配置IDEA版本及其输出目录:File->Project Structure

![image.png]([object Object]&name=image.png&originHeight=612&originWidth=1016&size=106695&status=done&style=none&width=508)

8.添加web-app目录

File->Project Structure->Facets

9.配置webapp对应的路径

上下两个都要配置

10.成功添加webapp目录

11.项目创建完成

相关的配置文件配置

所需的jar包

org.springframework
spring-context
5.0.5.RELEASE
org.springframework
spring-expression
5.0.5.RELEASE
org.springframework
spring-beans
5.0.5.RELEASE
org.springframework
spring-aop
5.0.5.RELEASE
org.springframework
spring-aspects
5.0.5.RELEASE
org.example
Spring-tx
1.0-SNAPSHOT
org.aspectj
aspectjweaver
1.8.13
org.springframework
spring-jdbc
5.0.5.RELEASE
org.mybatis
mybatis
3.4.5
org.mybatis
mybatis-spring
1.3.2
io.github.orange1438
mybatis-generator-core
1.3.5
com.github.jsqlparser
jsqlparser
0.9.1
com.github.pagehelper
pagehelper
3.7.5
mysql
mysql-connector-java
8.0.16
c3p0
c3p0
0.9.1.2
com.alibaba
druid
1.1.10
jstl
jstl
1.2
org.springframework
spring-webmvc
5.0.5.RELEASE
org.springframework
spring-web
5.0.5.RELEASE
org.apache.tomcat
servlet-api
6.0.29
javax.servlet.jsp
jsp-api
2.1
org.springframework
spring-test
5.0.5.RELEASE
junit
junit
4.13
test
commons-beanutils
commons-beanutils
1.9.1
commons-collections
commons-collections
20040616
commons-fileupload
commons-fileupload
1.3.1
commons-io
commons-io
2.6
commons-lang
commons-lang
2.6
commons-logging
commons-logging
1.2
net.sf.ezmorph
ezmorph
1.0.6
dev.galasa
gson
2.8.5
org.hamcrest
hamcrest-core
1.3
test
com.fasterxml.jackson.core
jackson-annotations
2.9.8
com.fasterxml.jackson.core
jackson-core
2.9.8
com.fasterxml.jackson.core
jackson-databind
2.9.8
javax.servlet
javax.servlet-api
3.1.0
net.sf.json-lib
json-lib
2.4
com.github.akarazhev
json-simple
1.2
javax.servlet.jsp
jsp-api
2.1
jstl
jstl
1.2
log4j
log4j
1.2.17

web.xml文件配置

web.xml文件的作用

web.xml是web项目的配置文件,一般的web工程都会用到web.xml来配置,方便大型开发。web.xml主要用来配置Filter,Listener,Servlet等。当你的web工程没用到这些时,你可以不用web.xml文件来配置你的web工程。

具体配置

characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
true
characterEncodingFilter
/*
hiddenHttpMethodFilter
org.springframework.web.filter.HiddenHttpMethodFilter
hiddenHttpMethodFilter
/*
contextConfigLocation
classpath:Spring/applicationContext.xml
org.springframework.web.context.ContextLoaderListener
dispatcherServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:SpringMvc/springMvc.xml
1
dispatcherServlet
/
404
/WEB-INF/errors/404.jsp
500
/WEB-INF/errors/500.jsp
index.jsp

Spring 的ApplicationContext.xml文件配置

ApplicationContext.xml文件配置什么

配置注解扫描,配置bean对象,事务管理器等等,就是spring容器的配置文件

具体配置

SpringMvc的配置文件配置

SpringMvc.xml配置什么

配置拦截器,以及对Controller注解的扫描,视图解析器等等

具体配置

10485760
UTF-8

Mybatis的配置文件

Mybatis配置文件配置什么

配置的东西都可以集成到SpringApplication中,包括别名等等

这里的都集成到springApplication中了没有配置

数据库配置文件的具体配置

datasource.connection.driver_class=com.mysql.jdbc.Driver#设置数据库的连接地址及编码方式datasource.connection.url=jdbc:mysql://localhost:3309/StudentInformation?useUnicode=true&characterEncoding=utf-8datasource.connection.username=rootdatasource.connection.password=1234#连接池保持的最小连接数,default : 3(建议使用)datasource.connection.minPoolSize=3#连接池中拥有的最大连接数,如果获得新连接时会使连接总数超过这个值则不会再获取新连接,而是等待其他连接释放,所以这个值有可能会设计地很大,default : 15(建议使用)datasource.connection.maxPoolSize=15#连接的最大空闲时间,如果超过这个时间,某个数据库连接还没有被使用,则会断开掉这个连接。如果为0,则永远不会断开连接,即回收此连接。default : 0 单位 s(建议使用)datasource.connection.maxIdleTime=0#连接池在无空闲连接可用时一次性创建的新数据库连接数,default : 3(建议使用)datasource.connection.acquireIncrement=3#连接池为数据源缓存的PreparedStatement的总数。由于PreparedStatement属于单个Connection,所以这个数量应该根据应用中平均连接数乘以每个连接的平均PreparedStatement来计算。同时maxStatementsPerConnection的配置无效。default : 0(不建议使用)datasource.connection.maxStatements=0#连接池为数据源单个Connection缓存的PreparedStatement数,这个配置比maxStatements更有意义,因为它缓存的服务对象是单个数据连接,如果设置的好,肯定是可以提高性能的。为0的时候不缓存。default : 0(看情况而论)datasource.connection.maxStatementsPerConnection=0#连接池初始化时创建的连接数,default : 3(建议使用)datasource.connection.initialPoolSize=3#用来配置测试空闲连接的间隔时间。测试方式还是上面的两种之一,可以用来解决MySQL8小时断开连接的问题。因为它保证连接池会每隔一定时间对空闲连接进行一次测试,从而保证有效的空闲连接能每隔一定时间访问一次数据库,将于MySQL8小时无会话的状态打破。为0则不测试。default : 0(建议使用)datasource.connection.idleConnectionTestPeriod=0#连接池在获得新连接失败时重试的次数,如果小于等于0则无限重试直至连接获得成功。default : 30(建议使用)datasource.connection.acquireRetryAttempts=30#如果为true,则当连接获取失败时自动关闭数据源,除非重新启动应用程序。所以一般不用。default : false(不建议使用)datasource.connection.breakAfterAcquireFailure=false#性能消耗大。如果为true,在每次getConnection的时候都会测试,为了提高性能,尽量不要用。default : false(不建议使用)datasource.connection.testConnectionOnCheckout=false#配置当连接池所有连接用完时应用程序getConnection的等待时间。为0则无限等待直至有其他连接释放或者创建新的连接,不为0则当时间到的时候如果仍没有获得连接,则会抛出SQLException。其实就是acquireRetryAttempts*acquireRetryDelay。default : 0(与上面两个,有重复,选择其中两个都行)datasource.connection.checkoutTimeout=30000#如果为true,则在close的时候测试连接的有效性。default : false(不建议使用)datasource.connection.testConnectionOnCheckin=false#配置一个表名,连接池根据这个表名用自己的测试sql语句在这个空表上测试数据库连接,这个表只能由c3p0来使用,用户不能操作。default : null(不建议使用)datasource.connection.automaticTestTable=c3p0TestTable#连接池在获得新连接时的间隔时间。default : 1000 单位ms(建议使用)datasource.connection.acquireRetryDelay=1000#为0的时候要求所有的Connection在应用程序中必须关闭。如果不为0,则强制在设定的时间到达后回收Connection,所以必须小心设置,保证在回收之前所有数据库操作都能够完成。这种限制减少Connection未关闭情况的不是很适用。建议手动关闭。default : 0 单位 s(不建议使用)datasource.connection.unreturnedConnectionTimeout=0#这个配置主要是为了快速减轻连接池的负载,比如连接池中连接数因为某次数据访问高峰导致创建了很多数据连接,但是后面的时间段需要的数据库连接数很少,需要快速释放,必须小于maxIdleTime。其实这个没必要配置,maxIdleTime已经配置了。default : 0 单位 s(不建议使用)datasource.connection.maxIdleTimeExcessConnections=0#配置连接的生存时间,超过这个时间的连接将由连接池自动断开丢弃掉。当然正在使用的连接不会马上断开,而是等待它close再断开。配置为0的时候则不会对连接的生存时间进行限制。default : 0 单位 s(不建议使用)datasource.connection.maxConnectionAge=0

日志文件的配置

### direct log messages to stdout ###log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.Target=System.outlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n### direct messages to file mylog.log ###log4j.appender.file=org.apache.log4j.FileAppenderlog4j.appender.file.File=c:/mylog.loglog4j.appender.file.layout=org.apache.log4j.PatternLayoutlog4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n### set log levels - for more verbose logging change 'info' to 'debug' ###log4j.rootLogger=INFO, stdout

以上就是第二讲的具体内容,就是一些配置文件的简单配置

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

你可能感兴趣的文章
Metasploit CGI网关接口渗透测试实战
查看>>
Metasploit Web服务器渗透测试实战
查看>>
MFC模态对话框和非模态对话框
查看>>
Moment.js常见用法总结
查看>>
MongoDB出现Error parsing command line: unrecognised option ‘--fork‘ 的解决方法
查看>>
mxGraph改变图形大小重置overlay位置
查看>>
MongoDB可视化客户端管理工具之NoSQLbooster4mongo
查看>>
Mongodb学习总结(1)——常用NoSql数据库比较
查看>>
MongoDB学习笔记(8)--索引及优化索引
查看>>
mongodb定时备份数据库
查看>>
mppt算法详解-ChatGPT4o作答
查看>>
mpvue的使用(一)必要的开发环境
查看>>
MQ 重复消费如何解决?
查看>>
mqtt broker服务端
查看>>
MQTT 保留消息
查看>>
MQTT 持久会话与 Clean Session 详解
查看>>
MQTT工作笔记0007---剩余长度
查看>>
MQTT工作笔记0009---订阅主题和订阅确认
查看>>
Mqtt搭建代理服务器进行通信-浅析
查看>>
MS Edge浏览器“STATUS_INVALID_IMAGE_HASH“兼容性问题
查看>>