快速搭建ssm环境

使用maven快速构建ssm环境
1.pom依赖包引入



org.springframework
spring-webmvc
5.1.5.RELEASE



org.springframework
spring-jdbc
5.1.5.RELEASE



org.springframework
spring-aspects
5.1.5.RELEASE



org.mybatis
mybatis
3.4.2



org.mybatis
mybatis-spring
1.3.1



com.alibaba
druid
1.1.3



mysql
mysql-connector-java
8.0.15



javax.servlet
jstl
1.2



javax.servlet
servlet-api
2.5
provided



junit
junit
4.12



org.springframework
spring-test
5.1.5.RELEASE
test




2.web.xml配置





contextConfigLocation
classpath:spring-*.xml


org.springframework.web.context.ContextLoaderListener



charactorEncoding
org.springframework.web.filter.CharacterEncodingFilter

encoding
UTF-8



charactorEncoding
/*



springmvc
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:springmvc.xml

1


springmvc
/*



3.配置springmvc.xml

xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" >xmlns:p="http://www.springframework.org/schema/p"
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.xsd
http://www.springframework.org/schema/context >http://www.springframework.org/schema/context/spring-context-4.3.xsd">


    






class="org.springframework.http.converter.StringHttpMessageConverter>">


text/html;charset=UTF-8






class="org.springframework.web.servlet.view.InternalResourceViewRes>olver">






4.spring-service.xml配置



>


5.spring-mybatis.xml配置

xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" >xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans >http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context >http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop >http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx >http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">

location="classpath:mysql.properties"/>

class="com.alibaba.druid.pool.DruidDataSource">
>







class="org.mybatis.spring.SqlSessionFactoryBean">

value="classpath:mapper/*.xml">




class="org.mybatis.spring.mapper.MapperScannerConfigurer">


value="sessionFactory">









6.mysql.properties配置
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/demo?>useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B>8&useSSL=false
jdbc.username=root
jdbc.password=root


7.UserMapper.xml配置




完成上述配置后环境就搭配好了(以上部分存在bug,需要删除>)

你可能感兴趣的:(快速搭建ssm环境)