- 浏览: 343739 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
mcseer:
我按照设置,但没有生效。能否协助
Asterisk中MixMonitor的参数b,接通后才录音 -
hbxfyxw:
过来看看文周书记,文周书记的总结很好很实用
(可行)easyui 实现 panel 拖动效果 -
hbxfyxw:
(惨痛教训) java runtime().exec() 提示 No such file or directory -
hwzyyx:
hbxfyxw 写道过来看看黄师傅,黄师傅行文走笔娓娓道来,受 ...
(原创)easyui 页面加载慢的原因及解决办法 -
hbxfyxw:
过来看看黄师傅,黄师傅行文走笔娓娓道来,受教了
(原创)easyui 页面加载慢的原因及解决办法
1. 先配置 PersistenceUnit ,在 persistence.xml 中
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="CallBackUnit" transaction-type="RESOURCE_LOCAL">
<!-- 配置JPA的实现提供者 -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.aaa.callback.dao.entity.TPredialQueue</class>
<class>com.aaa.callback.dao.entity.TPredialQueueHistory</class>
</persistence-unit>
</persistence>
2. 在 applicationContext.xml 中配置entityManagerFactory
<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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd ">
<!-- 配置JPA实体管理器工厂 -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="CallBackUnit" />
<property name="persistenceXmlLocation" value="classpath:persistence.xml" />
</bean>
</beans>
3. 配置事务管理器,在 2的配置文件中加入
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory">
<ref bean="entityManagerFactory" />
</property>
</bean>
上面是配置好了事务管理器,但是要让其起作用还得配置以下的内容
4. 配置advice
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" propagation="REQUIRED" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
注:这里的 get*是指以get为开头的方法的事件为只读事务,
5. 配置aop
<aop:config>
<aop:pointcut expression="execution(public * com.aaa.callback.service..*.*(..))" id="txPointcut"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
</aop:config>
通过以上步骤之后,基本功能就实现了。
当然,还要加入 hibernate.properties的配置
#####################################################################
####Hibernate 属性参数,也可以删除该文件在persistence.xml文件中定义
#####################################################################
#是否显示SQL语句
hibernate.show_sql=true
#是否格式化SQL语句
hibernate.format_sql=true
#数据库更新策略(none,validate,create,create-drop,update)
hibernate.hbm2ddl.auto=update
#自动探测实体(class,hbm)
hibernate.archive.autodetection=class
#Hibernate 连接设置
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=UTF-8
hibernate.connection.username=root
hibernate.connection.password=123456
#C3P0连接池配置
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=300
hibernate.c3p0.max_statements=50
hibernate.c3p0.acquire_increment=1
hibernate.c3p0.idle_test_period=3000
#是否使用查询缓存
hibernate.cache.use_query_cache=true
#是否使用二级缓存
hibernate.cache.use_second_level_cache=false
#二级缓存实现提供者
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
#Hibernate方言设置,生成特定数据库和优化的SQL语句
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
- Linux_下_tomcat6.0安装.zip (7.1 KB)
- 下载次数: 6
发表评论
-
Java 静态代理模式与装饰者模式的本质区别
2019-10-22 11:00 695我们在学习 Spring 时会先学习代理 ... -
使用quartz 致命的问题反思
2018-11-22 11:00 950一段时间没有用 quartz 了,所以就随手写一个守护程序 ... -
JAVA 以GET方式提交数据中文乱码,如果配置tomcat配置
2018-04-18 10:15 404解决方法非常简单,只要在 tomcat/conf/ser ... -
Eclipse 下载安装插件提示 Read time out (超时) 解决办法
2017-05-25 15:09 1586加入以下参数到eclipse.ini文件中,找到-vmarg ... -
(可行) 使用 sigar 时,出现UnsatisfiedLinkError
2017-04-26 11:13 488sigar 工具类主要是用于收集操作系统信息及系统信 ... -
(惨痛教训) java runtime().exec() 提示 No such file or directory
2017-04-07 15:14 4120最近花了三天解决 ... -
(测试可用)JSP 页面通过 ajax 导出附件(下载文件)实际
2016-04-12 11:02 777在前端不能真的以 ajax 去请求,而是应该用隐藏的 for ... -
(转)jquery操作select(取值,设置选中)
2014-08-06 18:15 883每一次操作select的时候,总是要出来翻一下资料,不如自己 ... -
<jsp:include ><jsp:forward> 配合 <jsp:param> 乱码问题解决
2013-07-22 02:04 1582在 JSP 动作元素: <jsp:inclu ... -
centos 安装 JDK 1.6 时,出现 unrecognized class file version
2013-04-10 11:02 1066出现这种情况,主要是因为CENTOS 5.0 的系统已经预安 ... -
tomcat 的web项目CPU、内存占用100%(经测试可行)
2012-12-13 19:41 1389近期上线的项目运行时,发现CPU有时能占到100% ... -
JAVA RMI 外网访问实例
2012-11-01 10:57 0JAVA RMI 使用分布式程序变得简单 -
(转)java生成Excel(JXL类库)
2012-07-06 15:32 915jxl是java操作excel的工具, 在开源世界中,有两套比 ... -
linux 下安装 jdk
2011-08-24 08:36 1143在linux 下安装 JDK, 也不会很难,按以下的步骤来就行 ... -
java 取得 src 下的文件
2011-07-25 15:20 795PropertyFileUtils p = new Prope ... -
eclipse 插件安装不上解决办法
2011-05-24 14:44 1189有时候安装eclipse插件时,发现插件及link 都写好了, ... -
Hibernate 最基本的内容
2011-02-23 20:52 943Hibernate 的所有操作都基于Session进行的,增、 ... -
Linux中JDK-JRE的安装和配置方法
2011-02-14 12:10 1767一.安装JDK 从sun网站上直接下载JDK:htt ... -
用commons-logging与log4j 输入日志的配置
2011-02-10 22:50 12381. commons-logging.properties ... -
Maven的web项目如果在eclipse中无法被tomcat识别时
2011-01-28 16:10 2718用dos进入项目所在目录,然后执行: mvn -Dwt ...
相关推荐
这是整合SpringMVC+Spring+SpringDataJPA+Hibernate简单的实现登录的功能,用的是mysql数据库,这是一个web Project 如果你用的是JavaEE6那么你要注意bean-validator.jar和weld-osgi-bundle.jar与slf4j的jar包冲突。...
Maven整合Spring+SpringMVC+Hibernate+SpringDataJPA
spring4.0.1 springMVC jpa2.0 hibernate4.3.7 框架整合
NULL 博文链接:https://ll-feng.iteye.com/blog/1908511
springmvc+springjpa+hibernate整合简例
velocity spring jpa hibernate 整合
Maven整合Spring+SpringMVC+Hibernate+SpringDataJPA+JdbcTemplate一个简单的DEMO
将_Shiro_作为应用的权限基础_五:SpringMVC+Apache_Shiro+JPA(hibernate)整合配置
本项目整合spring_jpa_hibernate_shiro,spring_jpa_hibernate_shiro.zip 里有代码,spring_jpa_hibernate常用的小弟就没有单独说明了,在项目配置文件里写得比较清楚,小弟在主要是shiro权限控制做了单独说明,如有...
NULL 博文链接:https://prowl.iteye.com/blog/519618
通过参考和引用传智播客的免费教程,将springmvc4.1.6与hibernate4.3.10提供的JPA实现整合,使用mysql5.6.25,在MyEclipse2014中测试通过。可以作为web开发的基础框架使用。 使用说明: 1.需要安装mysql,并创建名为...
这是jsf+spring2.5+jpa(hibernate)的jar包,很多人为了jsj环境而配置半天,在此提供jar包共享。注:除了ajax4jsf和tomahawk-1.1.3.jar,因为csdn只让我上传20mb,大家自己可以下一下自己试试。
附件有整合好的PPT和项目例子配置文件在PPT的备注里和相应的jar包、使用最新的注解加扫描
包含构建spring+springmvc+jpa(hibernate)架构框架的所需文件
工作用了springmvc+jpa+spring这么长时间,这段时间正好有点时间就想整合一下,但在整合过程中遇到了各种问题,上网查了很多资料但讲的都很模糊或者是没有注释,在我一步一步的试验中终于整合成功了,做为我自已以后...
2017 spring data jpa+spring4.2+springmvc+hibernate4.3 maven环境intellij idea增删改查实例
Struts2+Spring+JPA(Hibernate)项目所需要的jar包
spring springmvc hibernate 整合 使用了maven管理jar 持久层 用了 spring data jpa
Spring Hibernate整合要点之JPA 1 依赖包 2 注解实体 3 DAO实现 4 JPA配置 5 spring配置 6 修改web.xml
Spring2.5整合JPA(Hibernate实现)所需的JAR包