pom.xml配置

<dependencies>
<!-- hibernate begin -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.2.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0.0.Final</version>
<exclusions>
<exclusion>
<artifactId>javax.el-api</artifactId>
<groupId>javax.el</groupId>
</exclusion>
<exclusion>
<artifactId>javax.el</artifactId>
<groupId>org.glassfish.web</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- hibernate end -->
<!-- spring begin -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.6.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.2.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<!-- spring end --> <!-- servlet begin -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
<!-- servlet end -->
<!-- jstl begin -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- jstl end -->
<!-- druid begin -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.15</version>
</dependency>
<!-- druid end -->
<!-- apache commons begin -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>20030825.184428</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>20030825.183949</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
<!-- apache commons end -->
<!--logger begin -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
<!-- logger end --> <!-- JSON begin -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<!-- JSON end --> <!-- mysqlDriver begin -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
<!-- mysqlDriver end --> </dependencies> db.properties配置 db.driverClass=com.mysql.jdbc.Driver
db.jdbcUrl=jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf-8
db.user=root
db.password=root
db.initialSize=1
db.minIdle=1
db.maxActive=20
db.maxWait=60000
db.timeBetweenEvictionRunsMillis=60000
db.minEvictableIdleTimeMillis=300000
db.poolPreparedStatements=true
db.maxPoolPreparedStatementPerConnectionSize=20 log4j.properties配置 #spring
log4j.rootLogger=INFO,stdout,other
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %m %n
log4j.appender.other=org.apache.log4j.RollingFileAppender
log4j.appender.other.File=${webapp.root}/WEB-INF/logs/log.log
log4j.appender.other.MaxFileSize=1024KB
log4j.appender.other.MaxBackupIndex=1000
og4j.appender.other.Threshold=INFO
log4j.appender.other.layout=org.apache.log4j.PatternLayout
log4j.appender.other.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}] %l %t %m %n
#hibernate
log4j.logger.org.hibernate=other
log4j.logger.org.hibernate.hql.ast.AST=other
log4j.logger.org.hibernate.SQL=other
log4j.logger.org.hibernate.type=other
log4j.logger.org.hibernate.cache=other
log4j.logger.org.hibernate.transaction=other
log4j.logger.org.hibernate.jdbc=other Spring.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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:task="http://www.springframework.org/schema/task"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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/task
http://www.springframework.org/schema/task/spring-task-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/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"
default-lazy-init="true"> <!-- 包扫描 -->
<context:component-scan base-package="cn.bdqn.smvc" />
<context:annotation-config /> <!-- 向Spring容器中加载properties文件 -->
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:db.properties</value>
</list>
</property>
</bean> <!-- JPA整合 -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter" />
<property name="packagesToScan">
<array>
<value>cn.bdqn.smvc.entity</value>
</array>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean> <!-- 指定使用jpa -->
<jpa:repositories base-package="cn.bdqn.smvc"
transaction-manager-ref="transactionManager"
entity-manager-factory-ref="entityManagerFactory" /> <!-- 将hibernate所有工作交由JPA来实现 -->
<bean id="hibernateJpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /> <!-- 配置事务管理 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean> <!-- 事务处理过程使用注解来完成 -->
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" /> <!-- 数据源配置,使用应用内的DBCP数据库连接池 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close">
<property name="driverClassName" value="db.driverClass"/><propertyname="url"value="{db.jdbcUrl}" />
<property name="username" value="db.user"/><propertyname="password"value="{db.password}" />
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="db.initialSize"/><propertyname="minIdle"value="{db.minIdle}" />
<property name="maxActive" value="db.maxActive"/><!−−配置获取连接等待超时的时间−−><propertyname="maxWait"value="{db.maxWait}" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="db.timeBetweenEvictionRunsMillis"/><!−−配置一个连接在池中最小生存的时间,单位是毫秒−−><propertyname="minEvictableIdleTimeMillis"value="{db.minEvictableIdleTimeMillis}" />
<property name="validationQuery" value="SELECT 'x' from dual" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements" value="db.poolPreparedStatements"/><propertyname="maxPoolPreparedStatementPerConnectionSize"value="{db.maxPoolPreparedStatementPerConnectionSize}" />
</bean> <!-- 启动对@AspectJ(面向切面)注解的支持 -->
<aop:aspectj-autoproxy />
</beans>

Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(一)的更多相关文章

  1. Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(二)

    SpringMVC.xml配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=&qu ...

  2. 联系 管理 Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(三)

    hibernate注解实体类示例 package cn.bdqn.smvc.entity; import java.io.Serializable; import javax.persistence. ...

  3. Spring Boot入门-快速搭建web项目

    Spring Boot 概述: Spring Boot makes it easy to create stand-alone, production-grade Spring based Appli ...

  4. springmvc+maven搭建web项目

    1.创建一个maven project 为spring1 2.进行项目的配置:默认的java 1.5 在properties中选择project facts项目进行配置,反选web之后修改java环境 ...

  5. springmvc+maven搭建web项目之二 通过另一种方式配置spring

    1.创建maven web项目 2. 配置pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x ...

  6. Spring+Druid+SpringMVC的搭建(附Demo)

    最近公司事情比较少,便想利用这段空闲时间做一个自己的博客. 前端界面已经搞好,感谢杨姐的模板,自己稍微把模板没有的模块给补全了. 今天便开始自己的SSM框架搭建,数据库链接是采用数据库连接池.先上个项 ...

  7. SpringMVC Memcached 搭建WEB项目缓存框架

    最近做的项目一直在使用memcached作为缓存来缓存各种数据,现在BOSS要在项目上加上缓存.并把任务交给我.便琢磨怎么解决这个问题. 看了很多文章,写的比较详尽靠谱的就是这篇了http://www ...

  8. springMVC+Hibernate4+Spring整合一(配置文件部分)

    本实例采用springMvc hibernate 与 spring 进行整合, 用springmvc 取代了原先ssh(struts,spring,hibernate)中的struts来扮演view层 ...

  9. Java EE 学习(9):IDEA + maven + spring 搭建 web(5)- 博客文章管理

    转载:Gaussic(一个致力于AI研究却不得不兼顾项目的研究生) . 注:在阅读本文前,请先阅读: Java EE 学习(5):IDEA + maven + spring 搭建 web(1) Jav ...

随机推荐

  1. 【leetcode❤python】 20. Valid Parentheses

    #-*- coding: UTF-8 -*-#利用栈的思想#如果输入的左测扩则入栈,如果输入为右侧扩,判断其是否与当前栈顶配对,如果匹配则删除这一对,否则return False#'(', ')', ...

  2. BZOJ 1513 [POI2006]Tet-Tetris 3D

    题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1513 题意:三维空间,有一些立方体在垂直下落.立方体的左下角坐标(x,y)以及长宽 ...

  3. .Net需要掌握的知识

    一.C#开发 1.C#基础 变量定义 如何变量的初始化 变量的作用域 常量 字符串处理 使用正则表达式 什么是CTS类型?数据类型如何分类以及各个数据类型范围 类型的转化分类 显式转换何隐式转化如何区 ...

  4. linux 中的快捷键

    终端快捷键 tab=补全 ctrl+a=开始位置 ctrl+e=最后位置 ctrl+k=删除此处至末尾所有内容 ctrl+u=删除此处至开始所有内容 ctrl+d=删除当前字母 ctrl+w=删除此处 ...

  5. 表生成器@ TableGenerator

    将当前主键的值单独保存到一个数据库的表中,主键的值每次都是从指定的表中查询来获得,这种生成主键的方式也是很常用的.这种方法生成主键的策略可以适用于任何的数据库,不必担心不同数据库不兼容造成的问题. 使 ...

  6. java读取文件多种方法

    1.按字节读取文件内容2.按字符读取文件内容3.按行读取文件内容 4.随机读取文件内容 public class ReadFromFile {     /**      * 以字节为单位读取文件,常用 ...

  7. nessus网页报错: Scans can not be saved without a policy. Please create a policy before proce

    Policies添加一个用户就好了暂时还不懂什么意思以后知道再补..............

  8. SQL 批量删除数据表

    ) while(exists(select * from sysobjects where name like '表名前缀%')) begin select @name=name from sysob ...

  9. ios 学习线路(图片)(摘录)

    iOS学习路线

  10. 02~ 一步一步教你使用 SVN之SVN 的介绍

    SVN的介绍 一.学习SVN的主要内容的介绍 1.基本操作:学习SVN有哪些基本操作 2.服务器端的安装配置:SVN中必不可少的2个环境之一,会在下面的课程中介绍服务器如何去安装和配置 3.客户端软件 ...