搭建ssm项目环境

1.首先准备好pom.xml文件,导入相关的jar包:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
cn.ljj
ssm
0.0.1-SNAPSHOT
war





   


junit
junit
4.12



   


log4j
log4j
1.2.17



org.slf4j
slf4j-api
1.7.21



   org.slf4j
   slf4j-log4j12
   1.7.21
   test



       
       


com.alibaba
fastjson
1.2.31




com.fasterxml.jackson.core
jackson-databind
2.8.8



com.github.pagehelper
pagehelper
5.0.0




org.mybatis.generator
mybatis-generator-core
1.3.1




commons-fileupload
commons-fileupload
1.3.1



       
       

org.springframework
spring-webmvc
4.3.7.RELEASE




org.springframework
spring-jdbc
4.3.7.RELEASE




org.springframework
spring-test
4.3.7.RELEASE




org.springframework
spring-aspects
4.3.7.RELEASE
 

       



org.mybatis
mybatis
3.4.2




org.mybatis
mybatis-spring
1.3.1

         
         



c3p0
c3p0
0.9.1



mysql
mysql-connector-java
5.1.41



         


taglibs
standard
1.1.2



   javax.servlet.jsp.jstl
   jstl
   1.2



   javax.servlet
   jstl
   1.2



javax.servlet
javax.servlet-api
3.0.1
provided

        



2.配置web.xml文件


xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">




contextConfigLocation
classpath:applicationContext*.xml





org.springframework.web.context.ContextLoaderListener





dispatcherServlet
org.springframework.web.servlet.DispatcherServlet


contextConfigLocation
classpath:springmvc.xml




dispatcherServlet
/




CharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
utf-8


forceRequestEncoding
true


forceResponseEncoding
true



CharacterEncodingFilter
/*



HiddenHttpMethodFilter
org.springframework.web.filter.HiddenHttpMethodFilter


HiddenHttpMethodFilter
/*


HttpPutFormContentFilter
org.springframework.web.filter.HttpPutFormContentFilter


HttpPutFormContentFilter
/*



index.html
index.htm
index.jsp



3:配置mybatis-config.xml


  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">















4.配置springmvc.xml


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">




















       
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">      
           
             
           
             
           
             
   


5.配置applicationContext.xml文件


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">

     

expression="org.springframework.stereotype.Controller" />

























































                         






6.dbConfig.properties

jdbc.jdbcUrl=jdbc:mysql://localhost:3306/ssm
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.user=root
jdbc.password=admin

7.mybatis逆向生成Mapper的配置(mbg.xml,可选择不配置,手动编写实体类以及Mapper)


  PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
  "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">








connectionURL="jdbc:mysql://localhost:3306/ssm" userId="root"
password="admin">









targetProject=".\src\main\java">












targetPackage="cn.ljj.dao" targetProject=".\src\main\java">











8.在项目中加入日志文件log4j.properties

# Global logging configuration\uff0c\u5efa\u8bae\u5f00\u53d1\u73af\u5883\u4e2d\u8981\u7528debug
log4j.rootLogger=DEBUG, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n


项目目录如下:


这样基于maven环境的ssm项目搭建完毕了,希望能够帮到大家~











你可能感兴趣的:(ssm相关配置)