在pom.xml中配置(要使用spring框架就需引入)
org.springframework
spring-context
5.0.5.RELEASE
1.在pom.xml中(引入和数据库相关的坐标)
mysql
mysql-connector-java
5.1.39
org.springframework
spring-jdbc
5.0.5.RELEASE
com.alibaba
druid
1.1.10
或
c3p0
c3p0
0.9.1.2
2.jdbc.properties配置文件
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test
jdbc.username=root
jdbc.password=root
3.在applicationContext中
引入context命名空间和约束路径:(目的是为了扫描组件和加载配置文件)
或
在pom.xml中配置
org.springframework
spring-test
5.0.5.RELEASE
junit
junit
4.12
test
1.在pom.xml中导入坐标
org.springframework
spring-context
5.0.5.RELEASE
org.aspectj
aspectjweaver
1.8.13
2.在applicationContext.xml 配置文件中导入aop命名空间
1.在pom.xml中引入事务的相关坐标
org.springframework
spring-tx
5.0.5.RELEASE
2.在applicationContext.xml 配置文件中
1)导入事务命名空间
2)创建平台事务管理器
3)使用注解配置声明式事务控制
1.在pom.xml中
org.springframework
spring-web
5.0.5.RELEASE
2.在web.xml(先加载web.xml成功后,启动服务器)中
contextConfigLocation
classpath:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
1.在pom.xml中
org.springframework
spring-context
5.0.5.RELEASE
org.springframework
spring-webmvc
5.0.5.RELEASE
javax.servlet
servlet-api
2.5
provided
javax.servlet.jsp
javax.servlet.jsp-api
2.2.1
provided
com.fasterxml.jackson.core
jackson-core
2.9.0
com.fasterxml.jackson.core
jackson-databind
2.9.0
com.fasterxml.jackson.core
jackson-annotations
2.9.0
2.在spring-mvc.xml中配置(引入mvc命名空间)
或
和
或
3.在web.xml中
DispatcherServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring-mvc.xml
1
DispatcherServlet
/
CharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
CharacterEncodingFilter
/*
1.在pom.xml中
commons-fileupload
commons-fileupload
1.3.1
commons-io
commons-io
2.4
2.在spring-mvc.xml配置文件中(配置文件解析器)
1.在pom.xml中导入坐标
mysql
mysql-connector-java
5.1.26
org.mybatis
mybatis
3.4.6
junit
junit
4.12
2.在sqlMapConfig核心配置文件中
3.在xxxMapper.xml映射文件中
1.在pom.xml中
com.github.pagehelper
pagehelper
5.1.10
2.在sqlMapConfig.xml核心配置文件中
3.在测试中
/*在查询之前先设置分页参数*/
PageHelper.startPage(当前页,每页显示的条数);
1.pom.xml文件(导入坐标)
4.0.0
cn.itcast
ssm_demo
1.0-SNAPSHOT
war
org.mybatis
mybatis
3.4.6
mysql
mysql-connector-java
5.1.26
log4j
log4j
1.2.17
org.slf4j
slf4j-log4j12
1.8.0-beta4
junit
junit
4.12
org.springframework
spring-context
5.0.5.RELEASE
org.springframework
spring-jdbc
5.0.5.RELEASE
org.springframework
spring-test
5.0.5.RELEASE
org.springframework
spring-webmvc
5.0.5.RELEASE
javax.servlet
jstl
1.2
javax.servlet
javax.servlet-api
3.1.0
provided
javax.servlet.jsp
javax.servlet.jsp-api
2.2.1
provided
com.alibaba
druid
1.0.9
org.mybatis
mybatis-spring
1.3.2
com.fasterxml.jackson.core
jackson-databind
2.9.0
com.github.pagehelper
pagehelper
5.1.10
org.apache.tomcat.maven
tomcat7-maven-plugin
2.1
80
/
2.applicationContext.xml(spring的配置文件)
helperDialect=mysql
reasonable=true
3.spring-mvc.xml(springMVC的配置文件)
4.log4j.properties(日志文件)
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file mylog.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=c:/mylog.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.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=debug, stdout
5.jdbc.properties(配置数据库的信息)
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm
jdbc.username=root
jdbc.password=root
6.web.xml
dispatcherServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring-mvc.xml
1
dispatcherServlet
/
org.springframework.web.context.ContextLoaderListener
contextConfigLocation
classpath:applicationContext.xml
characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
characterEncodingFilter
/*
org.apache.maven.plugins
maven-compiler-plugin
1.8
utf-8
org.apache.tomcat.maven
tomcat7-maven-plugin
2.2
8080
/