admin
2021-02-06 e2c6372f29ae0a93d9f672ffad4613581ba3e201
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:cache="http://www.springframework.org/schema/cache"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:jms="http://www.springframework.org/schema/jms" xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd    
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd    
        http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd    
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd    
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd    
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd    
        http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.2.xsd    
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.2.xsd    
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd    
        http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd    
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd    
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd    
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
 
    <!-- 组件扫描 -->
    <context:component-scan base-package="com">
    </context:component-scan>
    <!--配置spring 注解 -->
    <context:annotation-config />
    <!-- 默认的注解映射的支持 -->
    <mvc:annotation-driven />
 
    <!-- 缓存注解支持 -->
    <cache:annotation-driven cache-manager="cacheManager" />
 
    <!-- Spring AOP支持 -->
    <aop:aspectj-autoproxy proxy-target-class="true" />
 
    <bean
        class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
 
    <!-- 配置hibernate属性 -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <!-- 注入连接池 ,是druid连接池-->
        <property name="dataSource" ref="druidDataSource"></property>
        <!-- 配置其他属性 -->
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                <prop key="hibernate.formate_sql">true</prop>
                <prop key="hibernate.hbm2ddl">none</prop>
                <!-- <prop key="hibernate.connection.autocommit">false</prop> -->
            </props>
        </property>
        <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
    </bean>
    <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource"
        init-method="init" destroy-method="close">
        <!-- 基本属性 url、user、password -->
        <!--
        <property name="url" value="jdbc:mysql://rdsswi5qt80crnoaqfxdfpublic.mysql.rds.aliyuncs.com:3306/new_beibei_video" />
        <property name="username" value="wk" />
        <property name="password" value="weikou2014" />
          -->
        
                <!-- 腾讯云 -->
        <!-- 
        外网:gz-cdb-gb8weleh.sql.tencentcdb.com:62998
        内网:172.16.16.2:3306
         -->
        <property name="url" value="jdbc:mysql://gz-cdb-gb8weleh.sql.tencentcdb.com:62998/new_beibei_video" />
        <property name="username" value="root" />
        <property name="password" value="Yeshi2016@" />
 
 
        <!-- 配置初始化大小、最小、最大 -->
        <property name="initialSize" value="30" />
        <property name="minIdle" value="50" />
        <property name="maxActive" value="500" />
 
 
        <!-- 配置获取连接等待超时的时间 -->
        <property name="maxWait" value="60000" />
 
        <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
        <property name="timeBetweenEvictionRunsMillis" value="60000" />
 
        <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
        <property name="minEvictableIdleTimeMillis" value="300000" />
 
        <property name="validationQuery" value="SELECT 'x'" />
        <property name="testWhileIdle" value="true" />
        <property name="testOnBorrow" value="false" />
        <property name="testOnReturn" value="false" />
 
 
        <!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
        <property name="poolPreparedStatements" value="false" />
        <property name="maxPoolPreparedStatementPerConnectionSize"
            value="20" />
        <!-- 配置监控统计拦截的filters -->
        <property name="filters" value="stat" />
    </bean>
    
    <!-- 事物 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager" />
 
 
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
 
    <!-- 视图解释类,如果用struts2,则springmvc的配置可不用,加了也没事 -->
    <!-- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
        <property name="prefix" value="/WEB-INF/pages/" /> <property name="suffix" 
        value=".jsp" /> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" 
        /> </bean> -->
 
 
    <!-- 处理静态资源 -->
    <mvc:resources location="/css/" mapping="/css/**" />
    <mvc:resources location="/js/" mapping="/js/**" />
    <mvc:resources location="/img/" mapping="/img/**" />
    <mvc:resources location="/html/" mapping="/html/**" />
    <mvc:resources location="/admin/new/" mapping="/admin/new/**" />
    <mvc:resources location="/druid/" mapping="/druid/**" />
 
 
    <task:annotation-driven scheduler="qbScheduler"
        mode="proxy" />
    <task:scheduler id="qbScheduler" pool-size="10" />
 
    <!-- 拦截器定义 -->
    <mvc:interceptors>
        <!-- 使用bean定义一个Interceptor,直接定义在mvc:interceptors根下面的Interceptor将拦截所有的请求 -->
        <!-- <mvc:interceptor> -->
        <!-- <mvc:mapping path="/api/**" /> -->
        <!-- <mvc:mapping path="*.action" /> -->
        <!-- 定义在mvc:interceptor下面的表示是对特定的请求才进行拦截的 -->
        <!-- <bean class="com.newvideo.interceptor.ApiSignInterceptor" /> -->
        <!-- <bean class="com.newvideo.interceptor.EncodingInterceptor" /> -->
        <!-- </mvc:interceptor> -->
        <bean class="com.newvideo.interceptor.EncodingInterceptor" />
    </mvc:interceptors>
 
 
    <!-- 缓存配置 -->
    <bean id="cacheManagerFactory"
        class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation" value="classpath:ehcache.xml" />
    </bean>
 
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
        <property name="cacheManager" ref="cacheManagerFactory" />
    </bean>
 
</beans>