zhitong.yu
2024-05-11 b72f8f8d58417eb6fb29672d8ac17cfafa46775c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?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"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="
       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.xsd
 
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd
 
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop.xsd">
 
    <!--<bean id="helloController" class="com.example.controller.HelloController"></bean>-->
 
    <!--开放注解功能-->
    <context:annotation-config/>
    <!--指定扫描和解析哪些包下面的类-->
    <context:component-scan base-package="com.hxzk"/>
    <context:component-scan base-package="com.hxzk.mapper"/>
    <!-- springMVC需要配置对controller层的扫描,这个配置必须在mvc配置文件当中。否则springMVC无法把请求转到Controller层 -->
    <!--开启mvc相关注解-->
    <mvc:annotation-driven/>
 
    <!--放行静态资源的-->
    <mvc:resources mapping="/CSS/**" location="/CSS/"/>
    <mvc:resources mapping="/JS/**" location="/JS/"/>
    <mvc:resources mapping="/Home/**" location="/Home/"/>
    <mvc:resources mapping="/Home/**" location="/Home/"/>
    <mvc:resources mapping="/Home/**" location="/Home/"/>
    <mvc:resources mapping="/TiaoZhuan/**" location="/TiaoZhuan/"/>
    <mvc:resources mapping="/HouTai/**" location="/HouTai/"/>
    <mvc:resources mapping="/api/**" location="/api/"/>
    <mvc:resources mapping="/font/**" location="/font/"/>
    <mvc:resources mapping="/Hindex/**" location="/Hindex/"/>
    <mvc:resources mapping="/fengmap/**" location="/fengmap/"/>
    <mvc:resources mapping="/images/**" location="/images/"/>
    <mvc:resources mapping="/Icon/**" location="/Icon/"/>
 
    <!--配置数据源-->
    <bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql:///hxzkuwb?characterEncoding=UTF8"/>
        <property name="username" value="root"/>
        <property name="password" value="123456"/>
    </bean>
 
    <!--配置Mybatis的SqlSessionFactoryBean-->
    <bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
        <property name="dataSource" ref="ds"/>
        <!--分页-拦截器-->
        <property name="plugins">
            <array>
                <bean class="com.github.pagehelper.PageInterceptor">
                    <property name="properties">
                        <!--使用下面的方式配置参数,一行配置一个(键=值)-->
                        <value>
                             helperDialect=mysql
                        </value>
                    </property>
                </bean>
            </array>
        </property>
    </bean>
    <!-- 配置MapperScan:用来扫描用户自定义的mapper接口 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.hxzk.mapper"/>
    </bean>
 
</beans>