========访问数据库的属于文件============

driver=com.hxtt.sql.access.AccessDriver
url=jdbc:access:/D:/eclipse/project/jee/workspace/jubweb2/src/message.mdb
dialect=org.hibernate.dialect.SQLServerDialect
path=D:/eclipse/project/jee/workspace/jubweb2/src/message.mdb
uname=
pwd=

==========application.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:p="http://www.springframework.org/schema/p"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
  xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-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/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-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/aop
    http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
    "> 
  <context:property-placeholder location="classpath:/META-INF/db.Properties" /><!--连接数据库的属性文件的路径-->
  <!-- 把标记了@Controller注解的类转换为bean-->    
     <context:component-scan base-package="com.jubangit.jubweb2.*" /> 
   <mvc:annotation-driven /> 
   
   <!--解决web.xml拦截非action路径的问题-->
   <mvc:default-servlet-handler/>
   
   <!--spring管理拦截器  -->
 <!--    <mvc:interceptors> 
    <bean class="com.jb.tool.JToolSystemInterceptor" /> 
 </mvc:interceptors>  -->
   
 
    <!-- 定义跳转的文件的前后缀 --> 
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <!--  <property name="prefix" value="/WEB-INF/jsp/" /> -->  <!-- jsp存放的路径-->
       <property name="suffix" value=".jsp" /> <!-- 指定跳转的页面为.jsp格式 -->
    </bean>
   
   
    <!--事物托管-->
   <!-- JPA Entity Manager Factory -->
 <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="dataSource">
  <property name="packagesToScan" value="com.jubangit.jubweb2.entity"/> <!--如果删除了persistence.xml,则需要指定实体所在的路径否则会报找不到该文件-->
  <property name="jpaDialect">
   <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
  </property>
  <property name="loadTimeWeaver">
   <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
  </property>
  <property name="persistenceProvider">
   <bean class="org.hibernate.ejb.HibernatePersistence"/><!-- 用于指定持久化实现厂商类 -->
  </property>
   <property name="jpaProperties">
             <props>
             <prop key="hibernate.dialect">${dialect}</prop>
       <prop key="hibernate.show_sql">true</prop>
                  <prop key="hibernate.max_fetch_depth">3</prop>
                  <prop key="hibernate.jdbc.fetch_size">18</prop>
                  <prop key="hibernate.jdbc.batch_size">10</prop>
       <!-- <prop key="hibernate.hbm2ddl.auto">create</prop> --><!-- 定义是否自动生成表,create表示每次加载都重新生成,update表示每次加载只是更新表 -->
               </props>
           </property>
 </bean>
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"><!--dbcp连接池-->
  <property name="driverClassName"><value>${driver}</value></property>
  <property name="url"><value>${url}</value></property>
  <property name="username"><value>${uname}</value></property>
  <property name="password"><value>${pwd}</value></property>
   <property name="initialSize"><value>5</value></property>
   <property name="maxActive"><value>50</value></property>
   <property name="maxIdle"><value>10</value></property>
   <property name="minIdle"><value>5</value></property>

 <property name="connectionProperties" value="charSet=gbk;"></property><!-- 解决UTF8编码连接读取Access数据库乱码问题 -->
    </bean>
   
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  <property name="entityManagerFactory" ref="entityManagerFactory" />
 </bean>
    <!-- 事物通知 -->
 <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="sav*" propagation="REQUIRED" rollback-for="Exception"/> <!-- rollback-for回滚事物,果存在一个事务,则支持当前事务。如果没有事务则开启  -->
   <tx:method name="del*" propagation="REQUIRED" rollback-for="Exception"/>
   <tx:method name="updat*" propagation="REQUIRED" rollback-for="Exception"/>
   <tx:method name="qry*" propagation="NOT_SUPPORTED" read-only="true"/>
   <tx:method name="*" propagation="NOT_SUPPORTED" read-only="true"/>
  </tx:attributes> 
 </tx:advice>
 <!-- 事物切入 -->
 
 <aop:config>
  <aop:pointcut id="cut"
   expression="execution(* com.jubangit.jubweb2.services.impl.*.*(..))" />
  <aop:advisor advice-ref="txAdvice" pointcut-ref="cut" />
 </aop:config>
   
   
</beans>

Spring+jpa+access的更多相关文章

  1. Spring JPA事务

    目录 1. 概述 促进阅读: 2. 配置不带XML的事务 3. 使用XML配置事务 4. @Transactional 注解 5. 潜在的陷阱 5.1. 事务和代理 5.2. 更改隔离级别 5.3. ...

  2. spring jpa 实体互相引用返回restful数据循环引用报错的问题

    spring jpa 实体互相引用返回restful数据循环引用报错的问题 Java实体里两个对象有关联关系,互相引用,比如,在一对多的关联关系里 Problem对象,引用了标签列表ProblemLa ...

  3. spring jpa 自定义查询数据库的某个字段

    spring jpa 提供的查询很强大, 就看你会不会用了. 先上代码, 后面在解释吧 1. 想查单个表的某个字段 在repository中 @Query(value = "select i ...

  4. Hibernate | Spring JPA | MySQL 使用过程遇到的一些问题

    1. 使用过程 2. 背景 3. 遇到问题 3.1 不指定Hibernate数据库方言,默认SQL生成方式 3.2 抛出异常Hibernate加入了@Transactional事务不会回滚 3.3 H ...

  5. Spring JPA 使用@CreatedDate、@CreatedBy、@LastModifiedDate、@LastModifiedBy 自动生成时间和修改者

    JPA Audit 在spring jpa中,支持在字段或者方法上进行注解@CreatedDate.@CreatedBy.@LastModifiedDate.@LastModifiedBy,从字面意思 ...

  6. Spring JPA学习笔记

    目录 什么是JPA? 引入配置 新建一个Entity Bean类 JPA的增删改查 新建操作接口 新建测试类 总结 什么是JPA? 什么是JDBC知道吧?数据库有Mysql,SQL Server,Or ...

  7. Spring JPA实现逻辑源码分析总结

    1.SharedEntityManagerCreator: entitymanager的创建入口 该类被EntityManagerBeanDefinitionRegistrarPostProcesso ...

  8. 使用Spring JPA中Page、Pageable接口和Sort类完成分页排序

    显示时,有三个参数,前两个必填,第几页,一页多少个size,第三个参数默认可以不填. 但是发现这个方法已经过时了,通过查看它的源码发现,新方法为静态方法PageRequest of(page,size ...

  9. spring jpa和mybatis整合

    spring jpa和mybatis整合 前一阵子接手了一个使用SpringBoot 和spring-data-jpa开发的项目 后期新加入一个小伙伴,表示jpa相比mybatis太难用,多表联合的查 ...

随机推荐

  1. kthread_stop引起的OOP

    1 使用kthread_create创建线程:     struct task_struct *kthread_create(int (*threadfn)(void *data), void *da ...

  2. Linux Autotools

    /********************************************************************** * Linux Autotools * 说明: * 我们 ...

  3. Windows Store APP- C# to get IP Address

    using Windows.Networking.Connectivity; public String GetIPString() { String ipString = String.Empty; ...

  4. (六)6.16 Neurons Networks linear decoders and its implements

    Sparse AutoEncoder是一个三层结构的网络,分别为输入输出与隐层,前边自编码器的描述可知,神经网络中的神经元都采用相同的激励函数,Linear Decoders 修改了自编码器的定义,对 ...

  5. [转载] FFmpeg 错误 C4996: ‘avcodec_alloc_frame’: 被声明为已否决 解决方法

    在 Visual Studio 2013 下编写 FFmpeg 程序时出错,错误如下: 出错代码如下: 解决方法为:将 avcodec_alloc_frame() 替换为 av_frame_alloc ...

  6. Defining Database and Instance【数据库与实例】

    Database: A collection of physical operating system files or disks. When usingOracle Automatic Stora ...

  7. click和onclick的区别

    onclick是绑定事件,click本身是方法作用是触发onclick事件,只要执行了元素的click()方法,下面有个示例,大家可以看看   Html代码 ? 1 2 3 4 5 6 7 8 9 1 ...

  8. in 和 exist 区别

    select * from Awhere id in(select id from B) 以上查询使用了in语句,in()只执行一次,它查出B表中的所有id字段并缓存起来.之后,检查A表的id是否与B ...

  9. MySQL与Oracle 差异比较之五存储过程&Function

    存储过程&Function 编号 类别 ORACLE MYSQL 注释 1 创建存储过程语句不同 create or replace procedure P_ADD_FAC(   id_fac ...

  10. K2 K2Blackpearl安装步骤详解(服务端)

    转:http://www.cnblogs.com/dannyli/archive/2011/11/30/2269485.html 以下是K2 Blackpearl的安装步骤,本人亲测可用哦. 1.安装 ...