`
xxxx1243
  • 浏览: 15807 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

spring 配置

阅读更多
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">
 
 	

	<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>
    
    
    
    <!-- session time -->
	<session-config>
		<session-timeout>10</session-timeout>
	</session-config>
    <!-- session time -->
    
    <!-- Character Encoding filter -->
	<filter>
		<filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!-- Character Encoding filter -->
  
    <!-- Spring -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:spring/*.xml</param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<listener>
	  <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
	</listener>
	<listener>
		<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
	</listener>
	<servlet>
		<servlet-name>*</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>*</servlet-name>
		<url-pattern>/spring/*</url-pattern>
	</servlet-mapping>
	<!-- Spring -->
	
	<!--Hibernate Open Session in View Filter-->
	<filter>
		<filter-name>openSessionInViewFilter</filter-name>
		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>openSessionInViewFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!--Hibernate Open Session in View Filter-->
  
  
	<!-- struts2 -->
	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
		<init-param>
			<param-name>config</param-name>
			<param-value>
					struts-default.xml,struts.xml
			</param-value>
		</init-param>
	</filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/page/*</url-pattern>
    </filter-mapping>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/index.jsp</url-pattern>
	</filter-mapping>
	<!-- struts2 -->
	
    
	<!-- restful web service -->
	<servlet>
	  <servlet-name>Jersey REST Service</servlet-name>
	<servlet-class>
	  com.sun.jersey.spi.container.servlet.ServletContainer
	</servlet-class>
	  <init-param>
	    <param-name>com.sun.jersey.config.property.packages</param-name>
	    <param-value>com.neusoft.*.ws</param-value>
	  </init-param>
	  <load-on-startup>-1</load-on-startup>
	</servlet>
	<servlet-mapping>
	  <servlet-name>Jersey REST Service</servlet-name>
	  <url-pattern>/rest/*</url-pattern>
	</servlet-mapping>   
	<!-- restful web service -->
	
	<!-- Reprot Image  -->
	<servlet>
		<servlet-name>JasperReportImageServlet</servlet-name>
		<servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>JasperReportImageServlet</servlet-name>
		<url-pattern>/image</url-pattern>
	</servlet-mapping>
 	<!-- Reprot Image  -->
 	
</web-app>





struts.xml

<?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.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"/> 
 	<constant name="struts.enable.DynamicMethodInvocation" value="true" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.i18n.encoding" value="UTF-8" />
	<constant name="struts.action.extension" value="do,action,"/>
	<constant name="struts.multipart.saveDir" value="/tmp"></constant>
	<constant name="struts.custom.i18n.resources" value="globalMessages" />
	<constant name="keys" value="key"></constant>
	<constant name="struts.ui.theme" value="simple"></constant>
	<constant name="struts.ognl.allowStaticMethodAccess" value="true"/>
	<constant name="struts.multipart.maxSize" value="104857600"></constant>
	
	<!-- 默认 -->
	<package name="super" namespace="/" extends="struts-default">  
		<interceptors>  
			<!-- 定义权限检查拦截器 类级别-->  
    		<interceptor name="checkLogin" class="com.neusoft.*.struts.action.interceptor.LoginInterceptor" />  
			<interceptor-stack name="storeStack">  
            	<interceptor-ref name="store">  
                	<param name="operationMode">AUTOMATIC</param>  
             	</interceptor-ref>  
            	<interceptor-ref name="paramsPrepareParamsStack" />  
         	</interceptor-stack>  
         	<interceptor-stack name="myDefaultStack">  
		        <!-- 定义拦截器栈包含user Login拦截器 -->  
		        <interceptor-ref name="checkLogin"></interceptor-ref>  
		        <interceptor-ref name="storeStack"></interceptor-ref>
		        <interceptor-ref name="defaultStack"></interceptor-ref>
		    </interceptor-stack>  
		</interceptors>
		<!-- 设置全局 全局默认的拦截器栈-->  
		<default-interceptor-ref name="myDefaultStack"></default-interceptor-ref>  
		<global-results>  
		    <result name="loginError" type="dispatcher">/login_timeout.jsp</result>   
		    <result name="roleError" type="dispatcher">/page/error/error.jsp</result>   
		    <result name="input" type="dispatcher">/page/error/input_error.jsp</result>
		</global-results> 
	</package>
	<include file="com/neusoft/*/struts/config/struts-stock.xml"/> 
	<include file="com/neusoft/*/struts/config/struts-template.xml"/> 
	<include file="com/neusoft/*/struts/config/struts-price.xml"/> 
	<include file="com/neusoft/*/struts/config/struts-order.xml"/>
	<include file="com/neusoft/*/struts/config/struts-basicdata.xml"/>
	<include file="com/neusoft/*/struts/config/struts-user.xml"/>
	 
</struts>




applicationContext-datasource.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: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-3.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
	   default-autowire="byName" default-lazy-init="false">


	<!-- 数据源定义 -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
		<property name="driverClass" value="com.mysql.jdbc.Driver"/>
		<property name="jdbcUrl" value="jdbc:mysql://10.10.52.141:3306/*_old?useUnicode=true&amp;characterEncoding=UTF-8"/>
		<property name="user" value="a"/>
		<property name="password" value="a"/>
	</bean>

	<!-- log4jdbc可以将数据源执行的sql将占位符?替换成字符,并以日志打印出来. log4j配置: log4j.logger.jdbc.sqltiming=INFO
	如oracle示例: 
		原来的sql: select * from user where birth_date = ? and username = ? and age > ?
		转换后sql: select * from user where birth_date = to_date('2010-08-13','yyyy-mm-dd') and username = 'badqiu' and age > 20
	 -->
	<bean id="log4jdbcInterceptor" class="net.sf.log4jdbc.DataSourceSpyInterceptor" />
    <bean id="dataSourceLog4jdbcAutoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
       <property name="interceptorNames">
           <list>
              <value>log4jdbcInterceptor</value>        
           </list>
       </property> 
       <property name="beanNames">
           <list>
              <value>dataSource</value>
           </list>
       </property>
    </bean>
</beans>



applicationContext-hibernate-dao.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"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
    default-autowire="byName" default-lazy-init="false">
	
	<!-- component-scan自动搜索@Component , @Controller , @Service , @Repository等标注的类  -->
	<context:component-scan base-package="com.**.dao"/>
	
	
	<!--Hibernate Annotation SessionFatory-->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		
		<!-- packagesToScan可以自动搜索某个package的全部标记@Entity class -->
		<property name="packagesToScan">
			<list>
				<value>com.neusoft.*.model</value>
			</list>
		</property>
		<!--<property name="mappingLocations" value="classpath*:com/creawor/demo/model/*.hbm.xml"/>-->
		<property name="hibernateProperties">
			<props>
				<!--常用数据库方言 MySQL5Dialect,SQLServerDialect,OracleDialect,SybaseDialect,DB2Dialect,HSQLDialect -->
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">true</prop>
				<prop key="hibernate.query.substitutions">true 1, false 0</prop>
				<prop key="hibernate.default_batch_fetch_size">4</prop>
				<prop key="javax.persistence.validation.mode">none</prop>
			</props>
		</property>
	</bean>
	
	<!--
	<bean id="transactionManager"    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">    
		<property name="dataSource" ref="dataSource" />
	</bean>
	 -->
	
	
	<!--Hibernate TransactionManager-->
	<!--  -->
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"/>
	</bean>
	
	 
	<!-- 
	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    </bean>
     -->
	
	<!-- 用于开启处理Lob类型数据 -->
	<!-- 
	<bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
		<property name="nativeJdbcExtractor">
			<bean class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor"></bean>
		</property>
	</bean>
	 -->
	
	
	
</beans>


applicationContext-resource.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:aop="http://www.springframework.org/schema/aop"
	   xmlns:context="http://www.springframework.org/schema/context"
	   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/aop http://www.springframework.org/schema/aop/spring-aop-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-2.5.xsd"
	   default-autowire="byName" default-lazy-init="false">

    <!-- 国际化,并且可以批定文件编码,可以使用classpath: 或者WEB-INF/ 前缀 -->
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    	<property name="basenames">
    		<list>
    			<value>classpath:i18n/messages</value>
    			<value>classpath:ValidationMessages</value>
    		</list>
    	</property>
    	<property name="defaultEncoding" value="UTF-8"/>
    	<property name="cacheSeconds" value="60"/>
    </bean>
    
	<!-- 属性文件读入,使用rapid中的JdbcPlaceholderConfigurer则可以从数据库读取配置信息 -->
	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath*:application.properties</value>
			</list>
		</property>
	</bean>
	
	<!--  激活 @Required @Autowired,JSR 250's @PostConstruct, @PreDestroy and @Resource 等标注 
	<context:annotation-config />
	-->
		
	<!-- 支持 @AspectJ 标记;
		<aop:aspectj-autoproxy/>
	-->

	<!-- 以 @Transactional 标注来定义事务 -->
	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

	<!-- 以AspectJ方式 定义 事务 -->
 
	<aop:config proxy-target-class="true">
		<aop:advisor pointcut="execution(* com.*..*.service.*Service.*(..))" advice-ref="txAdvice"/>
	</aop:config>
	

	<!-- 基本事务定义,使用transactionManager作事务管理,默认get* find*方法的事务为readonly,其余方法按默认设置.
			 默认的设置请参考Spring文档事务一章. -->
	
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
		<tx:method name="*"/>
		<!-- 
			<tx:method name="find*" read-only="true"/>
			<tx:method name="get*" read-only="true"/>
			<tx:method name="query*" read-only="true"/>
			<tx:method name="pageQuery*" read-only="true"/>
			<tx:method name="*" read-only="false"/>
		 -->
		</tx:attributes>
	</tx:advice>
	 
	
	<!-- 用于持有ApplicationContext,可以使用ApplicationContextHolder.getBean('xxxx')的静态方法得到spring bean对象 -->
	<!-- <bean class="org.hlj.framework.core.utils.holder.ApplicationContextHolder"/> -->

</beans>



applicationContext-service.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"
	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"    default-autowire="byName" default-lazy-init="false">

	<!-- component-scan自动搜索@Component , @Controller , @Service , @Repository等标注的类 -->
	<!-- 默认值如果适合,该项可以不用修改 -->
	<context:component-scan base-package="com.**.service" />

</beans>



*-servlet.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:aop="http://www.springframework.org/schema/aop"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

	<context:component-scan base-package="com.**.spring.xml" />
	
	<aop:aspectj-autoproxy proxy-target-class="true"/>
	
	<mvc:annotation-driven/>

	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" p:messageConverters-ref="messageConverters"/>
	<util:list id="messageConverters">
		<bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter" />
		<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
		<bean class="org.springframework.http.converter.StringHttpMessageConverter" />
		<bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" />
		<bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter" p:marshaller-ref="xmlMarshaller" p:unmarshaller-ref="xmlMarshaller"/>
		<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
	</util:list>
	<bean id="xmlMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
		<property name="streamDriver">
			<bean class="com.thoughtworks.xstream.io.xml.StaxDriver" />
		</property>
	</bean>
	
	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
	
	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
	
	<!-- 
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
		p:order="100" p:viewClass="org.springframework.web.servlet.view.JstlView"
		p:prefix="/WEB-INF/views/" p:suffix=".jsp" />
	
	<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
		<property name="converters">
			<list>
				<bean class="com.baobaotao.domain.StringToUserConverter" />
			</list>
		</property>
	</bean>
	
	<bean id="xmlMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
		<property name="streamDriver">
			<bean class="com.thoughtworks.xstream.io.xml.StaxDriver" />
		</property>
		<property name="annotatedClasses">
			<list>
				<value>com.baobaotao.domain.User</value>
			</list>
		</property>
	</bean>
   -->
</beans>



ehcache.xml

<?xml version="1.0" encoding="UTF-8"?>
 <!--timeToIdleSeconds 当缓存闲置n秒后销毁 -->
 <!--timeToLiveSeconds 当缓存存活n秒后销毁 -->
 <!--
 缓存配置
       name:缓存名称。
       maxElementsInMemory:缓存最大个数。
       eternal:对象是否永久有效,一但设置了,timeout将不起作用。
       timeToIdleSeconds:设置对象在失效前的允许闲置时间(单位:秒)。仅当eternal=false对象不是永久有效时使用,可选属性,默认值是0,也就是可闲置时间无穷大。
       timeToLiveSeconds:设置对象在失效前允许存活时间(单位:秒)。最大时间介于创建时间和失效时间之间。仅当eternal=false对象不是永久有效时使用,默认是0.,也就是对象存活时间无穷大。
       overflowToDisk:当内存中对象数量达到maxElementsInMemory时,Ehcache将会对象写到磁盘中。
       diskSpoolBufferSizeMB:这个参数设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区。
       maxElementsOnDisk:硬盘最大缓存个数。
       diskPersistent:是否缓存虚拟机重启期数据 Whether the disk store persists between restarts of the Virtual Machine. The default value is false.
       diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认是120秒。
       memoryStoreEvictionPolicy:当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU(最近最少使用)。你可以设置为FIFO(先进先出)或是LFU(较少使用)。
       clearOnFlush:内存数量最大时是否清除。
 -->
<ehcache>

	<diskStore path="java.io.tmpdir" />

	<!-- Cluster localhost setting -->
	<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
		properties="hostName=localhost, port=40001,socketTimeoutMillis=2000" />

	
	<cache name="dictCache" maxElementsInMemory="500" overflowToDisk="true" eternal="true">
		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
			properties="replicatePuts=false,replicateUpdatesViaCopy=false" />
	</cache>
	
	<cache name="eternalCache" maxElementsInMemory="500" overflowToDisk="true"
		eternal="false"
		timeToIdleSeconds="1200" timeToLiveSeconds="1200">
		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
			properties="replicatePuts=false,replicateUpdatesViaCopy=false" />
	</cache>
	<!--
		DefaultCache setting.
		Modify ehcache-safe.xml for timeToIdleSeconds,timeToLiveSecond,diskExpiryThreadIntervalSeconds
		Use ehcache-safe.xml default for maxElementsInMemory,maxElementsOnDisk,overflowToDisk,eternal Use ehcache default
		for memoryStoreEvictionPolicy,diskPersistent,.
	-->
	<defaultCache maxElementsInMemory="10000" overflowToDisk="true" eternal="false"
		memoryStoreEvictionPolicy="LRU" diskExpiryThreadIntervalSeconds="600"
		timeToIdleSeconds="3600" timeToLiveSeconds="100000" diskPersistent="false" />
</ehcache>



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics