手机版
你好,游客 登录 注册
背景:
阅读新闻

JPA + Spring + Struts2 配置

[日期:2011-12-01] 来源:Linux社区  作者:liu372267001 [字体:大 中 小]

Spring配置文件 

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  5.     xsi:schemaLocation="http://www.springframework.org/schema/beans  
  6.            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
  7.            http://www.springframework.org/schema/context  
  8.            http://www.springframework.org/schema/context/spring-context-2.5.xsd  
  9.            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd  
  10.            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">  
  11.     <aop:aspectj-autoproxy />  
  12.     <context:component-scan base-package="com.qksd" />  
  13.       
  14.     <bean id="entityManagerFactory"  
  15.         class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">  
  16.         <property name="persistenceUnitName" value="info" />  
  17.     </bean>  
  18.     <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">  
  19.         <property name="entityManagerFactory" ref="entityManagerFactory" />  
  20.     </bean>  
  21.   
  22.     <tx:annotation-driven transaction-manager="transactionManager" />  
  23.   
  24. </beans>  
  1. Persistence.xml  
  1. <?xml version="1.0"?>  
  2. <persistence xmlns="http://Java.sun.com/xml/ns/persistence"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"  
  5.     version="1.0">  
  6.   
  7.     <persistence-unit name="info" transaction-type="RESOURCE_LOCAL">  
  8.         <!--  
  9.             <jta-data-source>java:/dataSource</jta-data-source> 该属性  
  10.             执行在web容器中指定的dataSource JNDI 名称  
  11.         -->  
  12.         <provider>org.hibernate.ejb.HibernatePersistence</provider>  
  13.         <properties>  
  14.             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />  
  15.             <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />  
  16.             <property name="hibernate.connection.username" value="root" />  
  17.             <property name="hibernate.connection.password" value="123456" />  
  18.             <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/info?useUnicode=true&characterEncoding=UTF-8" />  
  19.             <property name="hibernate.max_fetch_depth" value="3" />  
  20.             <property name="hibernate.hbm2ddl.auto" value="update" />  
  21.             <property name="hibernate.jdbc.fetch_size" value="18" />  
  22.             <property name="hibernate.jdbc.batch_size" value="10" />  
  23.             <property name="hibernate.show_sql" value="true" />  
  24.             <property name="hibernate.format_sql" value="false" />  
  25.         </properties>  
  26.     </persistence-unit>  
  27. </persistence>  
Struts 2 使用的Convention插件,所以没有配置文件linux
相关资讯       Spring  Struts2  JPA 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款