Spring整合SSM配置文件

(1).配置创建连接池properties文件

druid.url=jdbc:mysql://localhost:3306/egoubuy?characterEncoding=utf-8
druid.password=123456
druid.username=root
druid.driverClassName=com.mysql.jdbc.Driver
druid.initialSize=5
druid.minIdle=3
druid.maxActive=20

(2).创建log4j.properties

# 全局日志配置
# 日志有四个级别:degbug,warn,info,debug
log4j.rootLogger=ERROR, stdout
# MyBatis 日志配置
log4j.logger.com.dao.BookDao=TRACE
# 控制台输出
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

(4).创建springMVC配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       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/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
        https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    

    <!--配置扫描controller包下的所有以@Controller注解修饰的类-->
    <context:component-scan base-package="这里是控制器的所在类,你可以放一起写,也可以分开写"></context:component-scan>

    <!--配置注解驱动-->
    <mvc:annotation-driven></mvc:annotation-driven>

    <!--放行静态资源文件-->
    <mvc:default-servlet-handler></mvc:default-servlet-handler>

    <!--视图解析器-->
    <bean id="resourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

    <!--配置文件上传解析器 吐过需要,你就打开注释commons-io commons-fileupload-->
    <!--<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="10000000"></property>
    </bean>-->

</beans>

(4).创建spring-mybatis 配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       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/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
        https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    

    <!--配置扫描controller包下的所有以@Controller注解修饰的类-->
    <context:component-scan base-package="这里是控制器的所在类,你可以放一起写,也可以分开写"></context:component-scan>

    <!--配置注解驱动-->
    <mvc:annotation-driven></mvc:annotation-driven>

    <!--放行静态资源文件-->
    <mvc:default-servlet-handler></mvc:default-servlet-handler>

    <!--视图解析器-->
    <bean id="resourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

    <!--配置文件上传解析器 吐过需要,你就打开注释commons-io commons-fileupload-->
    <!--<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="10000000"></property>
    </bean>-->

</beans>

复制代码

猜你喜欢

转载自blog.csdn.net/qq_45349018/article/details/104934088