SSH框架搭建配置
来源:互联网 发布:数据分析之量化投资 编辑:程序博客网 时间:2024/06/06 01:43
1、开发环境:MyEclipse、MySQL、jdk1.7.0_79、Tomcat 7.x
2、创建数据库
3、创建数据库链接配置文件(db.properties)
datasource.driverClassName=com.mysql.jdbc.Driver#数据库链接地址datasource.url=jdbc\:mysql\:///empmanagedatasource.username=数据库链接用户datasource.password=数据库链接密码hibernate.dialect=org.hibernate.dialect.MySQLDialecthibernate.show_sql=truehibernate.cache.class=org.hibernate.cache.EhCacheProviderhibernate.cache.query=falsec3p0.maxPoolSize=2000c3p0.minPoolSize=500c3p0.initialPoolSize=500c3p0.maxIdleTime=200c3p0.acquireIncrement=3c3p0.acquireRetryAttempts=30c3p0.acquireRetryDelay=1000c3p0.autoCommitOnClose=falsedbcp.initialSize=15dbcp.maxIdle=10dbcp.minIdle=1dbcp.maxActive=1000dbcp.logAbandoned=truedbcp.removeAbandoned=truedbcp.removeAbandonedTimeout=2000dbcp.maxWait=15000#set to 'SELECT 1' dbcp.validationQuery = "SELECT 1" #set to 'true' dbcp.testWhileIdle = true #some positive integer dbcp.timeBetweenEvictionRunsMillis = 300000 #set to something smaller than 'wait_timeout' dbcp.minEvictableIdleTimeMillis = 320000 #if you don't mind a hit for every getConnection(), set to "true" dbcp.testOnBorrow = "true" scheduler.Manager = falsedate=60000
4、struts.properties 文件
struts.action.extension=do,tg,actionstruts.objectFactory=spring#struts.enable.DynamicMethodInvocation=falsestruts.devMode=falsestruts.locale=zh_CNstruts.i18n.encoding=utf-8struts.multipart.maxSize=10240000
5、applicationContext.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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-lazy-init="true"> <context:annotation-config></context:annotation-config> <context:component-scan base-package="com.user.**"></context:component-scan> <!-- 导入资源文件 --> <context:property-placeholder location="classpath:db.properties"/> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${datasource.driverClassName}"></property> <property name="url" value="${datasource.url}"></property> <property name="username" value="${datasource.username}" /> <property name="password" value="${datasource.password}" /> <property name="removeAbandoned" value="true" /> <property name="removeAbandonedTimeout" value="300" /> <property name="timeBetweenEvictionRunsMillis" value="86400" /> <property name="testWhileIdle" value="true" /> <property name="validationQuery" value="SELECT 1 FROM dual" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="packagesToScan"> <list> <value>com.user.**.model</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.query.substitutions">true 1, false 0</prop> <prop key="hibernate.default_batch_fetch_size">4</prop> </props> </property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"></property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:advice id="advice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="alter*" propagation="REQUIRED"/> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="set*" propagation="REQUIRED"/> <tx:method name="register" propagation="REQUIRED"/> <tx:method name="del*" propagation="REQUIRED"/> <tx:method name="create*" propagation="REQUIRED"/> <tx:method name="process*" propagation="REQUIRED"/> <tx:method name="restore*" propagation="REQUIRED"/> <tx:method name="backup*" propagation="REQUIRED"/> <tx:method name="log*" propagation="REQUIRED"/> <tx:method name="giving*" propagation="REQUIRED"/> <tx:method name="auth*" propagation="REQUIRED"/> <tx:method name="sendMessage*" propagation="REQUIRED"/> <tx:method name="cust*" propagation="REQUIRED"/> <tx:method name="make*" propagation="REQUIRED"/> <tx:method name="inq*" propagation="REQUIRED"/> <tx:method name="list*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="(execution(* com.user..*Service.*(..)))" id="pointcut"/> <aop:advisor advice-ref="advice" pointcut-ref="pointcut"/> </aop:config> </beans>
6、web.xml文件
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name></display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>openSessionInViewerFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>openSessionInViewerFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list></web-app>
增、删、查、改的实现参考(http://blog.csdn.net/qq_39189632/article/details/78404536)
到这里我们的框架配置结束了,如果对你有帮助,请关注我。有不明白的可以留言…..
原码下载:http://download.csdn.net/download/qq_39189632/10046918
阅读全文
1 0
- SSH框架搭建配置
- SSH框架搭建+log4j配置
- ssh 搭建框架spring相关配置(1)
- ssh 搭建框架spring相关配置(2)
- 搭建SSH框架之配置Struts2
- ssh框架搭建完成后配置
- [SSH框架初学笔记]ssh环境搭建及配置
- S2S3H4 SSH框架 搭建 环境配置及测试
- 在J2EE Eclipse上配置Mysql----SSH框架搭建1
- 基于Eclipse搭建SSH框架:第一篇 配置struts2
- SSH框架搭建
- ssh框架搭建问题解决
- ssh框架搭建
- 快速搭建ssh框架
- SSH框架搭建流程
- SSH框架搭建
- 搭建ssh框架
- ssh 框架 搭建
- C++ 程序崩溃调用堆栈打印
- 高端智能冰箱成白电市场新宠,营造品质生活方式为上策
- 一图囊括所有ES6知识点结构
- local variable 'xxx' referenced before assignment
- 适配器模式
- SSH框架搭建配置
- 总结提高关键词排名最全的41个技巧
- LeetCode-22. Generate Parentheses
- Redis使用示例
- Python爬虫入门:Urllib库的高级使用
- UGUI坐标与世界坐标的转换
- java Excel解析
- qq引流新技能
- [noip2013]小朋友的数字(dp+规律)