首页 > 代码库 > maven工程web层的spring配置文档

maven工程web层的spring配置文档

1、引入jdbc配置文档

2、扫描文件

3、上传文件的设置

 

下面是例子:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:p="http://www.springframework.org/schema/p"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-4.1.xsd">

    <!-- 引入jdbc配置文件 -->
    <context:property-placeholder location="classpath:properties/jdbc.properties" />

    <!-- 扫描文件 -->
    <context:component-scan base-package="com.mmc.d4alc">
        <context:exclude-filter type="annotation"
            expression="org.springframework.stereotype.Controller" />
        <context:exclude-filter type="annotation"
            expression="org.springframework.web.bind.annotation.RestController" />
        <context:exclude-filter type="annotation"
            expression="org.springframework.web.bind.annotation.ControllerAdvice" />
    </context:component-scan>

    <!-- 上传文件的设置 ,maxUploadSize=-1,表示无穷大。uploadTempDir为上传的临时目录 -->  
   <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"    
        p:defaultEncoding="UTF-8"    
        p:maxUploadSize="-1"    
        p:uploadTempDir="file"    
     /> 

    

    
    <bean id="info"
        class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <array>
                <value>classpath:properties/info.properties</value>
                <value>classpath:properties/fileupload.properties</value>
            </array>
        </property>
    </bean>
    

</beans>

 

maven工程web层的spring配置文档