qq_28342873
没有伞就要努力奔跑
2016-11-22 02:58

移动端app后台框架,springmvc+spring+mybatis占用服务器内存太大是什么原因

  • spring
  • mybatis
  • 内存
  • 服务器
  • 框架

<?xml version="1.0" encoding="UTF-8"?>
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"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"
default-lazy-init="true">
<!-- Annotation Config -->
context:annotation-config/
<!-- mvc:annotation-driven/ -->
<!-- 扫描Service -->

<!-- jdbcTemplate -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource" ref="dataSource" />
</bean>

<!-- spring Task -->
<!-- <task:scheduled-tasks>
    <task:scheduled ref="taskJob" method="" cron=""/>
</task:scheduled-tasks>
<context:component-scan base-package=""></context:component-scan> -->

<!-- spring Task Annotation -->
<context:component-scan base-package="smart.smartutil.*"></context:component-scan>
<task:annotation-driven scheduler="myScheduler"/>
<task:scheduler id="myScheduler" pool-size="5"/>

<!-- ***************配置数据源************** -->
<!-- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:jeecg/template/jeecg_database.properties"></property>
</bean> -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name = "driverClassName" value = "com.microsoft.sqlserver.jdbc.SQLServerDriver" />

    <property name="url" value=""></property>
    <property name="username"><value>   </value></property>
    <property name="password"><value></value></property>
    <!-- 初始化连接大小 -->  
    <!-- 连接池最大使用连接数量 -->
    <property name="maxActive" value="10" />
    <!-- 连接池最大空闲 -->
    <property name="maxIdle" value="10" />
    <!-- 连接池最小空闲 -->
    <property name="minIdle" value="0" />
    <!-- 获取连接最大等待时间 -->
    <property name="maxWait" value="90000" />
    <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
    <property name="timeBetweenEvictionRunsMillis" value="60000" />
    <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
    <property name="minEvictableIdleTimeMillis" value="25200000" />
</bean>

<!-- ***************事务配置************** -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>

<aop:config>
    <aop:advisor pointcut="execution(* com.jeecg.service.*.*(..))"  advice-ref="txAdvice" />
    <aop:advisor pointcut="execution(* smart.service.*.*(..))"  advice-ref="txAdvice" />
    <aop:advisor pointcut="execution(* scott.service.*.*(..))"  advice-ref="txAdvice" />
    <!--
            <aop:aspect id="LogAspect" ref="logBean">
               <aop:pointcut id="smartService"  expression="execution(* smart.service.*.*(..))" />
               <aop:pointcut id="baseService"  expression="execution(* com.base.service.*.*(..))" />
               <aop:pointcut id="jeecgService"  expression="execution(* com.jeecg.service.*.*(..))" />
     -->
    <!--            <aop:before pointcut-ref="smartService" method="doBefore"/>   -->
    <!--            <aop:after pointcut-ref="smartService" method="doAfter"/>   -->
    <!--
               <aop:around pointcut-ref="smartService" method="doAround"/>
               <aop:around pointcut-ref="baseService" method="doAround"/>
               <aop:around pointcut-ref="jeecgService" method="doAround"/>
     -->
    <!--            <aop:after-throwing pointcut-ref="smartService" method="doThrowing" throwing="ex"/>   -->
    <!--
           </aop:aspect>
     -->
</aop:config>

<bean id="logBean" class="com.base.util.LogAspect" />

<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="get*" read-only="true" />
        <tx:method name="query*" read-only="true" />
        <tx:method name="find*" read-only="true" />
        <tx:method name="load*" read-only="true" />
        <tx:method name="select*" read-only="true" />
        <tx:method name="*" propagation="REQUIRED" rollback-for="Exception" />
    </tx:attributes>
</tx:advice>

<!-- 扫描 MyBatis Sql -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations">
        <list>
            <!-- <value>classpath:com/jeecg/mapper/*Mapper.xml</value>
            <value>classpath:scott/mapper/*/*Mapper.xml</value> -->
            <value>classpath:smart/mapper/*Mapper.xml</value>
        </list>
    </property>
    <property name="configLocation" value="classpath:mybatis-config.xml" />
</bean>

<!-- 扫描mapper.java  -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" autowire="byName">
    <property name="basePackage" value="com.jeecg.dao,scott.dao.*,smart.dao" />
    <property name="sqlSessionFactory" ref="sqlSessionFactory"/>
</bean>


<!-- Spring 工具类 -->
<bean id="springContextUtil" class="com.base.util.SpringContextUtil" />

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答