读书人

ssh环境筹建记录

发布时间: 2013-11-03 15:39:14 作者: rapoo

ssh环境搭建记录
<?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"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>BaseSSHDemo</display-name><!-- 定义spring配置文件的位置 --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext*.xml</param-value></context-param><!-- 定义log4j配置文件的位置 --><context-param><param-name>log4jConfigLocation</param-name><param-value>classpath:log4j.properties</param-value></context-param><!--Spring默认刷新Log4j配置文件的间隔,单位为millisecond --><context-param><param-name>log4jRefreshInterval</param-name><param-value>60000</param-value></context-param><!--web容器启动,自动加载ApplicationContext信息 --><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- web容器启动,加载log4j--><listener><listener-class>org.springframework.web.util.Log4jConfigListener</listener-class></listener><!-- spring支持request scope --><listener><listener-class>org.springframework.web.context.request.RequestContextListener</listener-class></listener><!-- 设置编码为UTF-8 --><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><!-- struts2 过滤器 --><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>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file>default.jsp</welcome-file></welcome-file-list></web-app>

?

?

2、log4j.properties

log4j.rootLogger=INFO, stdout, logfilelog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%nlog4j.appender.logfile=org.apache.log4j.RollingFileAppenderlog4j.appender.logfile.File=${baseWebApp.root}/WEB-INF/baseWebApp.loglog4j.appender.logfile.MaxFileSize=512KB# Keep three backup files.log4j.appender.logfile.MaxBackupIndex=3# Pattern to output: date priority [category] - messagelog4j.appender.logfile.layout=org.apache.log4j.PatternLayoutlog4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

?

3、定义数据源属性和hibernate属性initMySQL.properties

######################################################     datasource setting             #########################################################datasource.type=mysqldatasource.driverClassName=org.gjt.mm.mysql.Driverdatasource.url=jdbc:mysql://localhost:3306/sshDemo?useUnicode=true&characterEncoding=UTF-8datasource.username=rootdatasource.password=rootdatasource.systemUserId=2datasource.userOnlineTimeOut=3600datasource.backListLoginFailedTimeOut=300datasource.maxActive=10datasource.maxIdle=2datasource.maxwait=120000#datasource.whenExhaustedAction=1#datasource.validationQuery=select 1 from dual#datasource.testOnBorrow=true#datasource.testOnReturn=falsedatasource.minPoolSize=10datasource.maxPoolSize=20datasource.maxStatements=0datasource.numHelperThreads=10datasource.maxIdleTime=1800datasource.acquireIncrement=3datasource.initialPoolSize=3datasource.idleConnectionTestPeriod=900datasource.acquireRetryAttempts=30datasource.breakAfterAcquireFailure=truedatasource.testConnectionOnCheckout=falsehibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect#hibernate.dialect=org.hibernate.dialect.SQLServerDialectconnection.characterEncoding=UTF-8hibernate.jdbc.batch_size=25hibernate.fetch_size=50hibernate.show_sql=truehibernate.show_sql_format= truehibernate.connection.release_mode=after_transactionhibernate.generate_statistics=truehibernate.connection_release_mode=autohibernate.autoReconnect=truehibernate.cglib.use_reflection_optimizer=trueremind.removetime=2hibernate.cache.use_second_level_cache truehibernate.cache.provider_class org.hibernate.cache.EhCacheProvider

?

4、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:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"><!-- DataSource Definition, using c3p0 connection pool --><bean id="propertyConfigurer"value="${datasource.driverClassName}" /><property name="jdbcUrl" value="${datasource.url}" /><property name="user" value="${datasource.username}" /><property name="password" value="${datasource.password}" /><property name="minPoolSize" value="${datasource.minPoolSize}" /><property name="maxPoolSize" value="${datasource.maxPoolSize}" /><property name="maxIdleTime" value="${datasource.maxIdleTime}" /><property name="acquireIncrement" value="${datasource.acquireIncrement}" /><property name="maxStatements" value="${datasource.maxStatements}" /><property name="initialPoolSize" value="${datasource.initialPoolSize}" /><property name="idleConnectionTestPeriod" value="${datasource.idleConnectionTestPeriod}" /><property name="acquireRetryAttempts" value="${datasource.acquireRetryAttempts}" /><property name="breakAfterAcquireFailure" value="${datasource.breakAfterAcquireFailure}" /><property name="testConnectionOnCheckout" value="${datasource.testConnectionOnCheckout}" /></bean><!-- 会话工厂 --><bean id="sessionFactory"/></property><!-- 映射文件位置 1、mappingResources 2、mappingLocations 3、mappingDirectoryLocations <property name="mappingLocations"> <list> <value>classpath:/org/rico/business/entity/hbm/*.hbm.xml</value> </list> </property> <property name="packagesToScan"><list><value>org.rico.business.entity</value></list></property>--><!-- hibernate属性 --><property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="connection.characterEncoding">${connection.characterEncoding}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.format_sql">${hibernate.show_sql_format}</prop><prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop><prop key="hibernate.connection.release_mode">${hibernate.connection_release_mode}</prop><prop key="hibernate.autoReconnect">${hibernate.autoReconnect}</prop><prop key="hibernate.cglib.use_reflection_optimizer">${hibernate.cglib.use_reflection_optimizer}</prop><!-- <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop> <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop> <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_second_level_cache}</prop> --></props></property></bean><!-- =========== openSessionInViewInterceptor 延迟加载问题============== --><bean id="openSessionInViewInterceptor"ref="sessionFactory" /><!--如果使用延迟关闭方式 <property name="singleSession"> <value>false</value> </property> --></bean><!-- 事务管理器 --><bean id="transactionManager" /></property></bean><bean id="hibernateTemplate" /></property><property name="allowCreate"><value>false</value></property></bean><!-- 利用拦截器来管理事务 ,所有的bean共享一个代理 --><bean id="transactionProxyFactoryBean" abstract="true"><!-- 配置事务管理器 --><property name="transactionManager" ref="transactionManager" /><!-- 配置事务属性 --><property name="transactionAttributes"><props><prop key="delete*">PROPAGATION_REQUIRED</prop><prop key="add*">PROPAGATION_REQUIRED</prop><prop key="update*">PROPAGATION_REQUIRED</prop><prop key="save*">PROPAGATION_REQUIRED</prop><prop key="find*">PROPAGATION_REQUIRED,readOnly</prop><prop key="get*">PROPAGATION_REQUIRED,readOnly</prop></props></property></bean><!-- 配置事务 --><!-- AOP和TX配置 --><!-- 声明一个 Hibernate 3 的 事务管理器供代理类自动管理事务用 --><!-- 这是事务通知操作,使用的事务管理器引用自 transactionManager <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <!- - 切入点指明了在执行Service的所有方法时产生事务拦截操作 - -> <aop:pointcut id="allMethod" expression="execution(* org.rico.***.*(..))" /> <!- - 定义了将采用何种拦截操作,这里引用到 txAdvice - -> <aop:advisor advice-ref="txAdvice" pointcut-ref="allMethod"/> </aop:config> --><!-- 定义logic <bean id="logic" parent="transactionProxyFactoryBean"> <property name="target"> <bean name="code"><?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"    "http://struts.apache.org/dtds/struts-2.0.dtd"><struts><constant name="struts.enable.DynamicMethodInvocation" value="false" /><constant name="struts.devMode" value="false" /><!-- <include file="example.xml"/> --><package name="default" namespace="/" extends="struts-default"><default-action-ref name="index" /><action name="index"><result type="redirectAction"><param name="actionName">HelloWorld</param><param name="namespace">/example</param></result></action><action name="test" class="testAction"><result name="success">/index.jsp</result></action></package><!-- Add packages here --></struts>

?

?

?

读书人网 >编程

热点推荐