集成SSJ框架的applicationContext.xml的基本配置方法

发布时间:2021-07-05 17:38:24 作者:chen
来源:亿速云 阅读:141

这篇文章主要介绍“集成SSJ框架的applicationContext.xml的基本配置方法”,在日常操作中,相信很多人在集成SSJ框架的applicationContext.xml的基本配置方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”集成SSJ框架的applicationContext.xml的基本配置方法”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

<?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:aop="http://www.springframework.org/schema/aop"       xmlns:tx="http://www.springframework.org/schema/tx"       xmlns:jpa="http://www.springframework.org/schema/data/jpa"       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/aop http://www.springframework.org/schema/aop/spring-aop.xsd       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd       http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"><!--引入相应的properties文件-->    <context:property-placeholder location="classpath:jdbc.properties"/><!--扫描对应的包(带有各层的标志的注解@Repository, @Service,@Controller,@Autowired,@PersistenceContext)-->    <context:component-scan base-package="com.zh.aisell.service"/><!--配置连接池-->    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><!--连接池的四大要素-->        <property name="driverClassName" value="${jdbc.driverClassName}"/><property name="url" value="${jdbc.url}"/><property name="username" value="${jdbc.username}"/><property name="password" value="${jdbc.password}"/><!--maxActive: 最大连接数量 -->        <property name="maxActive" value="150" /><!--minIdle: 最小空闲连接 -->        <property name="minIdle" value="5" /><!--maxIdle: 最大空闲连接 -->        <property name="maxIdle" value="20" /><!--initialSize: 初始化连接 -->        <property name="initialSize" value="30" /><!-- 用来配置数据库断开后自动连接的 -->        <!-- 连接被泄露时是否打印 -->        <property name="logAbandoned" value="true" /><!--removeAbandoned: 是否自动回收超时连接 -->        <property name="removeAbandoned" value="true" /><!--removeAbandonedTimeout: 超时时间(以秒数为单位) -->        <property name="removeAbandonedTimeout" value="10" /><!--maxWait: 超时等待时间以毫秒为单位 1000等于60秒 -->        <property name="maxWait" value="1000" /><!-- 在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位. -->        <property name="timeBetweenEvictionRunsMillis" value="10000" /><!-- 在每次空闲连接回收器线程(如果有)运行时检查的连接数量 -->        <property name="numTestsPerEvictionRun" value="10" /><!-- 1000 * 60 * 30 连接在池中保持空闲而不被空闲连接回收器线程 -->        <property name="minEvictableIdleTimeMillis" value="10000" /><property name="validationQuery" value="SELECT NOW() FROM DUAL" /> </bean><!--配置entityManagerFactory-->    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"><!--注入连接池-->        <property name="dataSource" ref="dataSource"/><!--扫描对应的包(带@Entity的类)-->        <property name="packagesToScan" value="com.zh.aisell"/><!--配置适配器-->        <property name="jpaVendorAdapter"><bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"><!--是否显示sql-->                <property name="showSql" value="true"/><!--建表策略:true代表update-->                <property name="generateDdl" value="false"/><!--配置方言-->                <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect"/></bean></property></bean><!--配置事务管理器-->    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"><property name="entityManagerFactory" ref="entityManagerFactory"/></bean><!--支持事务(注解支持)-->    <tx:annotation-driven/><!-- Spring Data Jpa配置 -->    <!-- base-package:扫描的包 -->    <jpa:repositories base-package="com.zh.aisell.repository"                      entity-manager-factory-ref="entityManagerFactory"                      transaction-manager-ref="transactionManager"                      factory-class="com.zh.aisell.repository.BaseRepositoryFactoryBean"    /></beans>

到此,关于“集成SSJ框架的applicationContext.xml的基本配置方法”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

推荐阅读:
  1. 框架集成
  2. Mybatis applicationContext.xml配置方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

上一篇:Python中怎么获取字典的值

下一篇:linux怎么安装jdk和tomcat

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》