- 浏览: 9520 次
- 性别:
- 来自: 深圳
最新评论
applicationContext-config.xml //用于加载 .properties 属性文件 该文件放于classpath路径下 eg: jdbc.properties
<?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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> </list> </property> </bean> </beans>
applicationContext-dataAccess.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${connection.driver_class}"/> <property name="jdbcUrl" value="${jdbc.connection.url}"/> <property name="idleConnectionTestPeriod" value="${jdbc.pool.c3p0.idle_connection_test_period}" /> <property name="properties"> <props> <prop key="user">${jdbc.connection.username}</prop> <prop key="password">${jdbc.connection.password}</prop> <prop key="c3p0.acquire_increment">${jdbc.pool.c3p0.acquire_increment}</prop> <prop key="c3p0.max_size">${jdbc.pool.c3p0.max_size}</prop> <prop key="c3p0.min_size">${jdbc.pool.c3p0.min_size}</prop> </props> </property> </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="myDataSource"/> <property name="mappingDirectoryLocations"> <list> <value>classpath*:persist/user</value> </list> </property> <property name="hibernateProperties"> <props> <!--常用数据库方言 MySQL5Dialect,SQLServerDialect,OracleDialect,SybaseDialect,DB2Dialect,HSQLDialect --> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <!-- <prop key="hibernate.query.substitutions">true 1, false 0</prop> <prop key="hibernate.default_batch_fetch_size">4</prop> --> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="mySessionFactory"/> </bean> <aop:config> <aop:pointcut id="productServiceMethods" expression="execution(* com.dx.dao.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="productServiceMethods"/> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save" propagation="REQUIRED"/> <tx:method name="update" propagation="REQUIRED"/> <tx:method name="*" propagation="SUPPORTS" read-only="true"/> </tx:attributes> </tx:advice> <bean id="baseDao" class="com.dx.dao.impl.BaseDaoImpl"> <property name="sessionFactory" ref="mySessionFactory"></property> </bean> </beans>
applicatiionContext-user 用于service层业务bean的配置 目前没有东西。
<?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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> </beans>
hibernate 实体类的映射文件 .hbm.xml eg:User.hbm.xml 文件 放于conf文件夹下的persist/user下
文件结构图如下
web.xml配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>web_Services</display-name> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:context/applicationContext-*.xml /WEB-INF/applicationContext-security.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*</url-pattern> </filter-mapping> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> --> </web-app>
ok就酱紫了
发表评论
-
cxf + spring 开发基于web服务的分布式异构数据同步更新应用技术研究 (2)
2013-01-04 17:08 927编写客户端代码 下载 cxf2.6.1 我是用这个,解压配置 ... -
dao 层封装(利用spring + hibernate)
2012-12-19 21:24 1367接口 baseDao package com.dx. ... -
dwr + spring 实现ajax
2012-12-19 21:13 717利用dwr 可轻松实现ajax的实现 ... -
cxf + spring 开发基于web服务的分布式异构数据同步更新应用技术研究
2012-12-19 15:41 642本课题主要解决不同平台和不同应用系统之间的数据转换、数据同步和 ... -
spring3.1 mvc 对ajax的支持
2012-11-30 18:18 1420最近学习了一下spring mvc,其简单的配置和对ajax ... -
dwr +spring 实现数据推送
2012-11-30 16:49 2109dwr是java开发的轻量级框架,主要有两大核心功能 ...
相关推荐
spring mvc + spring + hibernate 全注解整合开发视频教程 11
简单struts+spring+hibernate搭建,配置,适合初学者
以上是springmvc+spring+hibernate整合基于eclipse,oracle开发
struts2+spring+hibernate 配置文件struts2+spring+hibernate 配置文件
博文链接:https://sydxide2006.iteye.com/blog/127824
spring mvc + spring + hibernate 全注解整合开发视频教程 06.haozip03
基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh...
Spring+SpringMVC+Hibernate+maven项目,适用初学者学习。
spring mvc + spring + hibernate 全注解整合开发视频教程 04
gwt+spring+hibernate整合例子,导入myeclipse中(要安gwt插件)即可用,数据库自己去代码中查看。包是精简版的,去掉很多不必要的包
Struts+Spring+Hibernate开发实例.pdf
Flex+Spring+Hibernate 整合的方式有多种,本文是利用flex builder插件,将flex与javaEE服务器端整合到一个工程里面,以便程序员可以在一个IDE里完成开发。
spring mvc + spring + hibernate 全注解整合开发视频教程 12
农业网站 (ssh) struts 2 +spring+ hibernate农业网站 (ssh) struts 2 +spring+ hibernate农业网站 (ssh) struts 2 +spring+ hibernate农业网站 (ssh) struts 2 +spring+ hibernate农业网站 (ssh) struts ...
使用Struts + Spring + Hibernate完成用户登陆笔记使用Struts + Spring + Hibernate完成用户登陆笔记
DWR+Struts+spring+hibernate的订货系统,自己添加的dwr功能
一个简单的spring+struts2+hibernate+mybatis整合(数据库脚本放在项目资源文件的sql目录下) 因为没想好mvc用springmvc好,还是struts2好 所以没有整合进去
Struts2+Spring+Hibernate+Jsp+Mysql5 项目申报系统.zip
Spring+Hibernate+Strust 整合开发步骤 Spring+Hibernate+Strust 整合开发步骤 Spring+Hibernate+Strust 整合开发步骤
Ajax+Spring+HibernateAjax+Spring+HibernateAjax+Spring+HibernateAjax+Spring+HibernateAjax+Spring+HibernateAjax+Spring+HibernateAjax+Spring+HibernateAjax+Spring+Hibernate