本文使用maven来构建ssm项目,至于开始如何使用eclipse搭建web项目就不介绍了,主要介绍最麻烦的框架配置内容。
1.项目结构如下图
2.pom.xml文件
[html] view plain copy
4.0.0
Demo
buoumall
war
0.0.1-SNAPSHOT
buoumall Maven Webapp
http://maven.apache.org
4.3.0.RELEASE
3.2.6
1.7.7
1.2.17
2.8.4
1.7.3
4.4.1
org.apache.velocity
velocity
1.7
com.baomidou
mybatis-plus
2.0.2
org.mybatis.generator
mybatis-generator-core
1.3.2
junit
junit
4.11
test
javax.servlet
javax.servlet-api
3.0.1
provided
org.springframework
spring-core
${spring.version}
org.springframework
spring-web
${spring.version}
org.springframework
spring-oxm
${spring.version}
org.springframework
spring-tx
${spring.version}
org.springframework
spring-jdbc
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-aop
${spring.version}
org.springframework
spring-context-support
${spring.version}
org.springframework
spring-test
${spring.version}
org.aspectj
aspectjweaver
${aspectj.version}
org.aspectj
aspectjrt
${aspectj.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
org.hibernate
hibernate-validator
5.3.4.Final
javax
javaee-api
7.0
mysql
mysql-connector-java
5.1.30
jstl
jstl
1.2
log4j
log4j
${log4j.version}
com.alibaba
fastjson
1.2.17
org.slf4j
slf4j-api
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
com.github.pagehelper
pagehelper
4.2.0
com.belerweb
pinyin4j
2.5.0
org.freemarker
freemarker
2.3.23
com.alibaba
druid
1.0.26
com.alibaba
dubbo
${dubbo.version}
com.google.guava
guava
18.0
org.codehaus.jackson
jackson-mapper-asl
1.9.13
org.apache.commons
commons-lang3
3.3.2
commons-collections
commons-collections
3.2.1
commons-beanutils
commons-beanutils
1.9.2
commons-logging
commons-logging
commons-io
commons-io
2.4
commons-codec
commons-codec
1.9
org.apache.httpcomponents
httpclient
${httpcomponents.version}
org.apache.httpcomponents
httpcore
${httpcomponents.version}
org.apache.httpcomponents
httpmime
${httpcomponents.version}
org.apache.httpcomponents
httpclient-cache
${httpcomponents.version}
commons-fileupload
commons-fileupload
1.3.1
com.googlecode.log4jdbc
log4jdbc
1.2
runtime
buoumall
org.apache.maven.plugins
maven-compiler-plugin
1.8
src/main/resources
false
src/main/conf/dev
false
3.web.xml的配置
[html] view plain copy
buoumall-business
contextConfigLocation
classpath:spring/applicationContext.xml
org.springframework.web.util.Log4jConfigListener
org.springframework.web.context.ContextLoaderListener
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
encodingFilter
/*
springMvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring/spring-mvc-servlet.xml
1
springMvc
/
480
4.在mybatis文件下建立mybatis-config.xml文件
[html] view plain copy
4.spring和mybatis的整合文件spring-bean-mybatis.xml
[html] view plain copy
dialect=mysql
offsetAsPageNum=true
rowBoundsWithCount=true
reasonable=true
supportMethodsArguments=true
params=count=countSql
autoRuntimeDialect=true
5.spring的配置文件applicationContext.xml
[html] view plain copy
6.spring MVC的配置文件spring-mvc-servlet.xml
[html] view plain copy
text/plain;charset=UTF-8
text/html;charset=UTF-8
application/json;charset=UTF-8
DisableCircularReferenceDetect
WriteMapNullValue
WriteNullListAsEmpty
WriteNullStringAsEmpty
WriteNullNumberAsZero
WriteNullBooleanAsFalse
WriteNonStringKeyAsString
BrowserCompatible
0
UTF-8
UTF-8
zh_CN
true,false
yyyy-MM-dd
HH:mm:ss
yyyy-MM-dd HH:mm:ss
#.##
true
true
ignore
104857600
4096
2.pom.xml文件
[html] view plain copy
4.0.0
Demo
buoumall
war
0.0.1-SNAPSHOT
buoumall Maven Webapp
http://maven.apache.org
4.3.0.RELEASE
3.2.6
1.7.7
1.2.17
2.8.4
1.7.3
4.4.1
org.apache.velocity
velocity
1.7
com.baomidou
mybatis-plus
2.0.2
org.mybatis.generator
mybatis-generator-core
1.3.2
junit
junit
4.11
test
javax.servlet
javax.servlet-api
3.0.1
provided
org.springframework
spring-core
${spring.version}
org.springframework
spring-web
${spring.version}
org.springframework
spring-oxm
${spring.version}
org.springframework
spring-tx
${spring.version}
org.springframework
spring-jdbc
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-aop
${spring.version}
org.springframework
spring-context-support
${spring.version}
org.springframework
spring-test
${spring.version}
org.aspectj
aspectjweaver
${aspectj.version}
org.aspectj
aspectjrt
${aspectj.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
org.hibernate
hibernate-validator
5.3.4.Final
javax
javaee-api
7.0
mysql
mysql-connector-java
5.1.30
jstl
jstl
1.2
log4j
log4j
${log4j.version}
com.alibaba
fastjson
1.2.17
org.slf4j
slf4j-api
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
com.github.pagehelper
pagehelper
4.2.0
com.belerweb
pinyin4j
2.5.0
org.freemarker
freemarker
2.3.23
com.alibaba
druid
1.0.26
com.alibaba
dubbo
${dubbo.version}
com.google.guava
guava
18.0
org.codehaus.jackson
jackson-mapper-asl
1.9.13
org.apache.commons
commons-lang3
3.3.2
commons-collections
commons-collections
3.2.1
commons-beanutils
commons-beanutils
1.9.2
commons-logging
commons-logging
commons-io
commons-io
2.4
commons-codec
commons-codec
1.9
org.apache.httpcomponents
httpclient
${httpcomponents.version}
org.apache.httpcomponents
httpcore
${httpcomponents.version}
org.apache.httpcomponents
httpmime
${httpcomponents.version}
org.apache.httpcomponents
httpclient-cache
${httpcomponents.version}
commons-fileupload
commons-fileupload
1.3.1
com.googlecode.log4jdbc
log4jdbc
1.2
runtime
buoumall
org.apache.maven.plugins
maven-compiler-plugin
1.8
src/main/resources
false
src/main/conf/dev
false
3.web.xml的配置
[html] view plain copy
buoumall-business
contextConfigLocation
classpath:spring/applicationContext.xml
org.springframework.web.util.Log4jConfigListener
org.springframework.web.context.ContextLoaderListener
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
encodingFilter
/*
springMvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring/spring-mvc-servlet.xml
1
springMvc
/
480
4.在mybatis文件下建立mybatis-config.xml文件
[html] view plain copy
4.spring和mybatis的整合文件spring-bean-mybatis.xml
[html] view plain copy
dialect=mysql
offsetAsPageNum=true
rowBoundsWithCount=true
reasonable=true
supportMethodsArguments=true
params=count=countSql
autoRuntimeDialect=true
5.spring的配置文件applicationContext.xml
[html] view plain copy
6.spring MVC的配置文件spring-mvc-servlet.xml
[html] view plain copy
text/plain;charset=UTF-8
text/html;charset=UTF-8
application/json;charset=UTF-8
DisableCircularReferenceDetect
WriteMapNullValue
WriteNullListAsEmpty
WriteNullStringAsEmpty
WriteNullNumberAsZero
WriteNullBooleanAsFalse
WriteNonStringKeyAsString
BrowserCompatible
0
UTF-8
UTF-8
zh_CN
true,false
yyyy-MM-dd
HH:mm:ss
yyyy-MM-dd HH:mm:ss
#.##
true
true
ignore
104857600
4096
utf-8
utf-8