项目1:

web.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="2.4"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>ProjectConsole</display-name>
    <description>Web UI</description>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
    </context-param>

    <!-- springMVC -->
    <servlet>
        <servlet-name>servlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/webmvc-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>servlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- Creates the Spring Container shared by all Servlets and Filters
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
     -->

    <!-- webapp do something -->
    <listener>
        <listener-class>com.vispractice.soa.lightesb.common.listener.EsbInitListener</listener-class>
    </listener>

    <!-- 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>

    <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>

    <filter>
        <filter-name>httpMethodFilter</filter-name>
        <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>httpMethodFilter</filter-name>
        <servlet-name>servlet</servlet-name>
    </filter-mapping>

    <!-- session time out setting -->
    <filter>
        <filter-name>SessionTimeOutFilter</filter-name>
        <filter-class>com.vispractice.soa.lightesb.common.filter.SessionTimeOutFilter</filter-class>
        <init-param>
            <param-name>logout</param-name>
            <param-value>/WEB-INF/views/login.jsp</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>SessionTimeOutFilter</filter-name>
        <url-pattern>*.html</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>SessionTimeOutFilter</filter-name>
        <url-pattern>*.htm</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>SessionTimeOutFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>SessionTimeOutFilter</filter-name>
        <url-pattern>*.do</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>SessionTimeOutFilter</filter-name>
        <url-pattern>*.json</url-pattern>
    </filter-mapping>

    <!-- DWR -->
    <servlet>
        <description>dwr-invoker</description>
        <servlet-name>dwr-invoker</servlet-name>
        <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
        <init-param>
            <param-name>classes</param-name>
            <param-value>com.vispractice.soa.lightesb.common.dwr.AutoTestCaseEvent</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>dwr-invoker</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>

    <!-- welcome list -->
    <welcome-file-list>
        <welcome-file>/WEB-INF/views/login.jsp</welcome-file>
    </welcome-file-list>

    <!-- 以下为FLEX -->
    <!-- Http Flex Session attribute and binding listener support -->
    <listener>
        <listener-class>flex.messaging.HttpFlexSession</listener-class>
    </listener>

    <!-- MessageBroker Servlet -->
    <servlet>
        <servlet-name>MessageBrokerServlet</servlet-name>
        <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
        <init-param>
            <param-name>services.configuration.file</param-name>
            <param-value>/WEB-INF/flex/services-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>    

    <servlet-mapping>
        <servlet-name>MessageBrokerServlet</servlet-name>
        <url-pattern>/messagebroker/*</url-pattern>
    </servlet-mapping>
</web-app>

webmvc-config.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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/mvc
       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

    <context:component-scan base-package="com.project.soa.light2esb">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
          <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
    </context:component-scan>

    <!-- root mapping
    <mvc:view-controller path="/" view-name="index"/>
    -->
    <mvc:annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving
        up static resources -->
    <mvc:resources location="/, classpath:/META-INF/web-resources/"
        mapping="/resources/**" />

    <mvc:interceptors>
        <bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"/>
        <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="lang"/>
    </mvc:interceptors>

    <mvc:default-servlet-handler />

    <bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application" p:fallbackToSystemLocale="false"/>
        <bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="errorSource" p:basenames="WEB-INF/i18n/errors" p:fallbackToSystemLocale="false"/>
        <!-- Store preferred language configuration in a cookie -->
    <bean class="org.springframework.web.servlet.i18n.CookieLocaleResolver" id="localeResolver" p:cookieName="locale"/>
    <!-- Resolves localized <theme_name>.properties files in the classpath to allow for theme support -->
    <bean class="org.springframework.ui.context.support.ResourceBundleThemeSource" id="themeSource">
        <property name="basenamePrefix" value="theme-" />
    </bean>
    <!-- Store preferred theme configuration in a cookie -->
    <bean class="org.springframework.web.servlet.theme.CookieThemeResolver" id="themeResolver" p:cookieName="theme" p:defaultThemeName="default"/>

    <bean id="handlerExceptionResolver" class="com.project.vis.platform.web.servlet.mvc.support.PlatformHandlerExceptionResolver"/>

    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"></bean>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver"></bean>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"></bean>

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources
        in the /WEB-INF/views directory -->
    <bean id="contentNegotiatingViewResolver"
        class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="order" value="#{T(org.springframework.core.Ordered).HIGHEST_PRECEDENCE}"/>
        <property name="mediaTypes">
            <map>
                <entry key="html" value="text/html" />
                <entry key="json" value="application/json" />
                <entry key="xml" value="application/xml" />
                <entry key="pdf" value="application/pdf" />
                <entry key="xsl" value="application/vnd.ms-excel" />
            </map>
        </property>
    </bean>

    <!--
    <bean id="resourceViewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="order" value="#{contentNegotiatingViewResolver.order+1}"/>
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>
    -->

    <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="order" value="#{contentNegotiatingViewResolver.order+1}"/>
        <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
    </bean>
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
          <list>
            <value>/WEB-INF/layouts/layouts.xml</value>
            <!-- Scan views directory for Tiles configurations -->
            <value>/WEB-INF/views/**/views.xml</value>
          </list>
        </property>
    </bean>
</beans>

applicationContext.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>

    <!--
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${database.driverClassName}"/>
        <property name="url" value="${database.url}"/>
        <property name="username" value="${database.username}"/>
        <property name="password" value="${database.password}"/>
        <property name="validationQuery" value="SELECT 1 FROM dual"/>
    </bean>
     -->

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName">
            <value>java:/datasources/visesbdb</value>
        </property>
    </bean>

    <!-- config dynamicDataSource -->
    <bean id="dynamicDataSource" class="com.vispractice.soa.lightesb.common.datasource.MutiDataSourceBean">
        <property name="targetDataSources">
            <map key-type="java.lang.String">
                <entry value-ref="dataSource" key="dataSource"></entry>
            </map>
        </property>
        <property name="defaultTargetDataSource" ref="dataSource"></property>
    </bean>

    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

    <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dynamicDataSource"/>
        <property name="packagesToScan">
            <list>
                <value>com.vispractice.soa.lightesb.bean</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
        <prop key="connection.useUnicode">true</prop>
        <prop key="connection.characterEncoding">UTF-8</prop>
        <prop key="hibernate.dialect">${hibernate.dialect}</prop>
        <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
        <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
        <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
        <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
        <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
        </props>
        </property>
    </bean>

    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager"/>
    <!-- Activates scanning of @Autowired -->
    <context:annotation-config/>

    <context:component-scan base-package="com.vispractice.soa.lightesb">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
    </context:component-scan>

    <bean id="multipartResolver"
        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="10000000"/>
    </bean>

    <!-- proxy module -->
    <bean id="proxy" class="com.vispractice.soa.lightesb.proxy.impl.comm.ProxyCreatorImpl"/>
    <bean id="route" class="com.vispractice.soa.lightesb.proxy.impl.route.RouteCreatorImpl"/>
</beans>

项目2:

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"
    metadata-complete="true"
    version="2.5">
    <display-name>system-web</display-name>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>

    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>system-web.root</param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:/applicationContext.xml,
            classpath*:/applicationContext-imports.xml
        </param-value>
    </context-param>
    <context-param>
        <param-name>spring.profiles.default</param-name>
        <param-value>development</param-value>
    </context-param>

    <!-- listener -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <listener>
        <listener-class>
            org.springframework.web.context.request.RequestContextListener
        </listener-class>
    </listener>

    <!-- filter -->
    <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>openEntityManagerInViewFilter</filter-name>
        <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>openEntityManagerInViewFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>shiroFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        <init-param>
            <param-name>targetFilterLifecycle</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>shiroFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>sitemeshFilter</filter-name>
        <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>sitemeshFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- MVC -->
    <servlet>
        <servlet-name>springServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring-mvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

spring-mvc.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:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

    <!-- 自动扫描且只扫描@Controller -->
    <context:component-scan base-package="com.project" use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
    </context:component-scan>

    <mvc:interceptors>
       <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"></bean>
       <bean class="com.project.f10.system.controller.interceptor.PermissionResourceInterceptor"></bean>
    </mvc:interceptors>

    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" /> 

    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <constructor-arg value="UTF-8" />
            </bean>
            <!-- 将Jackson2HttpMessageConverter的默认格式化输出设为true -->
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="prettyPrint" value="true"/>
                <property name="supportedMediaTypes">
                  <list>
                    <value>application/json;charset=UTF-8</value>
                    <value>text/json;charset=UTF-8</value>
                  </list>

            </property>
            </bean>
          </mvc:message-converters>
    </mvc:annotation-driven>

    <!-- 定义JSP文件的位置 -->
    <!--
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    -->

    <bean id="contentNegotiatingViewResolver"
        class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="order" value="#{T(org.springframework.core.Ordered).HIGHEST_PRECEDENCE}"/>
        <property name="mediaTypes">
            <map>
                <entry key="html" value="text/html" />
                <entry key="json" value="application/json" />
                <entry key="text" value="text/json" />
                <entry key="xml" value="application/xml" />
                <entry key="pdf" value="application/pdf" />
                <entry key="xsl" value="application/vnd.ms-excel" />
            </map>
        </property>
    </bean>

    <bean id="resourceViewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="order" value="#{contentNegotiatingViewResolver.order+1}"/>
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <!-- 定义无需Controller的url<->view直接映射  redirect:-->
    <mvc:view-controller path="/" view-name="redirect:/login/success"/>

    <!-- 组件js文件位置 -->
    <mvc:resources location="classpath:/META-INF/web-resources/" mapping="/web-resources/**" cache-period="31556926"/>

    <!-- 容器默认的DefaultServletHandler处理 所有静态内容与无RequestMapping处理的URL-->
    <mvc:default-servlet-handler/>    

    <!-- 将Controller抛出的异常转到特定View, 保持SiteMesh的装饰效果 -->
      <!--
    <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <property name="exceptionMappings">
            <props>
                <prop key="java.lang.Throwable">common/error/error</prop>
                <prop key="java.lang.Exception">common/error/error</prop>
                <prop key="java.lang.RuntimeException">common/error/error</prop>
            </props>
        </property>
        <property name="statusCodes">
            <props>
                <prop key="common/error/404">404</prop>
                <prop key="common/error/error">500</prop>
            </props>
        </property>
    </bean>
    -->
</beans>

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:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd"
    default-lazy-init="true">

    <description>Spring公共配置 </description>

    <!-- 使用annotation 自动注册bean, 并保证@Required、@Autowired的属性被注入 -->
    <context:component-scan base-package="com.project.**.dao,
                      com.project.**.service,
                      com.project.**.controller">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
    </context:component-scan>

    <!-- Spring Data Jpa配置 -->
     <jpa:repositories base-package="com.project.**.dao"  transaction-manager-ref="transactionManager" entity-manager-factory-ref="entityManagerFactory"/>

    <!-- 使用annotation定义事务 -->
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

    <!-- Jpa 事务配置 -->
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>

    <!-- Jpa Entity Manager 配置 -->
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/>
        <property name="packagesToScan" value="com.project.**.entity"/>
        <property name="jpaProperties">
            <props>
                <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
                <!--cache/ehcache-hibernate-local.xml  -->
                <prop key="net.sf.ehcache.configurationResourceName">cache/ehcache.xml</prop>
                <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>

                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
            </props>
        </property>
    </bean>

    <bean id="hibernateJpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="databasePlatform">
            <bean factory-method="getDialect" class="com.project.modules.persistence.Hibernates">
                <constructor-arg ref="dataSource"/>
            </bean>
        </property>
    </bean>

    <!-- JSR303 Validator定义 -->
     <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" >
       <property name="validationMessageSource" ref="messageSource"/>
       <property name="providerClass" value="org.hibernate.validator.HibernateValidator"/>
     </bean>

    <!-- 国际化文件配制,查找当前classpath以及jar包中的classpath,以第一个加载的属性KEY为主 -->
    <bean id="messageSource" class="com.project.f10.common.utils.ReloadableResourceBundleMessageSource">
        <property name="fileEncodings" value="utf-8"/>
        <property name="basenames">
            <list>
                <value>classpath*:i18n/messages*</value>
            </list>
        </property>
        <!-- 为flase 消息code必须存在,否则会抛出异常  如果为true,目前会导致validateMessages中的消息不能格式化 -->
        <property name="useCodeAsDefaultMessage" value="false"/>
    </bean>

    <!-- 加载所有的配制文件 -->
    <!--
    <context:property-placeholder  location="classpath*:conf/*.properties" ignore-unresolvable="true"/>

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>i18n/messages</value>
                <value>i18n/messages_tips</value>
                <value>i18n/messages_operation_log</value>
            </list>
        </property>
        <property name="useCodeAsDefaultMessage" value="true"/>
    </bean>
    -->

    <!-- production环境 -->
     <beans profile="production">
         <context:property-placeholder ignore-unresolvable="true"
            location="classpath*:/application.properties,
                      classpath*:conf/*-config.properties"
                      />
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
            <property name="driverClass" value="${datasource.driverClassName}" />
            <property name="jdbcUrl" value="${datasource.url}" />
            <property name="user" value="${datasource.username}" />
            <property name="password" value="${datasource.password}" />
            <property name="acquireIncrement" value="${c3p0.acquireIncrement}" />
            <property name="initialPoolSize" value="${c3p0.initialPoolSize}" />
            <property name="minPoolSize" value="${c3p0.minPoolSize}" />
            <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
            <property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
            <property name="idleConnectionTestPeriod" value="${c3p0.idleConnectionTestPeriod}" />
            <property name="maxStatements" value="${c3p0.maxStatements}" />
            <property name="numHelperThreads" value="${c3p0.numHelperThreads}" />
       </bean>
    </beans>

    <!-- local development环境 -->
    <beans profile="development">
        <context:property-placeholder ignore-resource-not-found="true"
            location="classpath*:/application.properties,
                        classpath*:/application.development.properties,
                        classpath*:/conf/*.development.properties
                        " />
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
            <property name="driverClass" value="${datasource.driverClassName}" />
            <property name="jdbcUrl" value="${datasource.url}" />
            <property name="user" value="${datasource.username}" />
            <property name="password" value="${datasource.password}" />
            <property name="acquireIncrement" value="${c3p0.acquireIncrement}" />
            <property name="initialPoolSize" value="${c3p0.initialPoolSize}" />
            <property name="minPoolSize" value="${c3p0.minPoolSize}" />
            <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
            <property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
            <property name="idleConnectionTestPeriod" value="${c3p0.idleConnectionTestPeriod}" />
            <property name="maxStatements" value="${c3p0.maxStatements}" />
            <property name="numHelperThreads" value="${c3p0.numHelperThreads}" />
       </bean>
    </beans>

    <!-- functional test 环境 -->
    <beans profile="functional">
        <context:property-placeholder ignore-resource-not-found="true"
            location="classpath*:/application.properties,
                        classpath*:/application.functional.properties,
                        classpath*:/conf/*.functional.properties" />    

        <!-- Tomcat JDBC连接池 -->
        <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">
            <property name="driverClassName" value="${jdbc.driver}" />
            <property name="url" value="${jdbc.url}" />
            <property name="username" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />
            <property name="defaultAutoCommit" value="false" />
        </bean>
        <!-- 初始化数据表结构 -->
        <!--
        <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL">
            <jdbc:script location="classpath*:sql/${db.type}/schema.sql" encoding="UTF-8"/>
            <jdbc:script location="classpath*:sql/${db.type}/views.sql" encoding="UTF-8"/>
            <jdbc:script location="classpath*:sql/${db.type}/data/import-data.sql" encoding="UTF-8"/>
        </jdbc:initialize-database>
        -->
    </beans>

    <!-- unit test环境 -->
    <beans profile="test">
         <context:property-placeholder ignore-resource-not-found="true"
            location="classpath*:/application.test.properties,
                        classpath*:/conf/*.test.properties
                        " />    

        <!-- Spring Simple连接池 -->
        <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
            <property name="driverClass" value="${jdbc.driver}" />
            <property name="url" value="${jdbc.url}" />
            <property name="username" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />
        </bean>
    </beans>

    <!-- standalone环境 -->
    <beans profile="standalone">
         <context:property-placeholder ignore-resource-not-found="true"
            location="classpath*:/application.properties,
                        classpath*:/application.standalone.properties,
                        classpath*:/conf/*.standalone.properties" />    

        <!-- Spring Simple连接池 -->
        <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
            <property name="driverClass" value="${jdbc.driver}" />
            <property name="url" value="${jdbc.url}" />
            <property name="username" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />
        </bean>
    </beans>

</beans>

springmvc配置文件-1的更多相关文章

  1. springmvc配置文件的主要内容

    springmvc配置文件的主要内容:

  2. SpringMVC配置文件 中 mvcview-controller 标签的使用

    一.<mvc:view-controller path=""/>标签的作用 工程WEB-INF目录下面的JSP页面,我们知道是不能直接使用URL访问到.需要通过控制器转 ...

  3. SpringMVC配置文件-web.xml的配置

    SpringMVC配置文件(重点) @Web.xml @核心拦截器(必配) <!-- spring 核心转发器,拦截指定目录下的请求,分配到配置的拦截路径下处理 --> <servl ...

  4. 新建springmvc配置文件

    新建spring或springmvc的配置文件时,需要先加入spring-bean-4.3.18.RELEASE.jar包,当然可以是其他版本,这样就可以在资源目录下,比如resources(Reso ...

  5. springmvc配置文件web.xml详解各方总结(转载)

    Spring分为多个文件进行分别的配置,其中在servlet-name中如果没有指定init-param属性,那么系统自动寻找的spring配置文件为[servlet-name]-servlet.xm ...

  6. springMVC配置文件位置及名称

    在web.xml文件内配置springMVC的DispatcherServlet的那个servlet内添加 <servlet> <servlet-name>mvc</se ...

  7. 【Spring】SpringMVC配置文件

    SpringMVC中一般会引入三个配置文件applicationContext.xml.dispatcher-servlet.xml(SpringMVC-servlet.xml).web.xml 1. ...

  8. springmvc配置文件

    1 springMVC的配置文件路径问题 https://www.cnblogs.com/ysloong/p/6071450.html

  9. springMVC配置文件web.xml与spring-servlet.xml与spring-jdbc.xml与logback.xml与redis.properties与pom.xml

    springMVC注解:@Controller @Service @Repository 分别标注于web层,service层,dao层. web.xml <?xml version=" ...

  10. Spring配置文件和SpringMVC配置文件 web.xml配置文件 保存自用

    话不多说,最近在周末自己抽时间写一些框架做的系统,当所有东西都需要自己配置时候发现自己压根记不住这么多类和路径,所以日常总结就变得尤为重要了 db-config.properties 将配置文件常量提 ...

随机推荐

  1. 王家林 大数据Spark超经典视频链接全集[转]

    压缩过的大数据Spark蘑菇云行动前置课程视频百度云分享链接 链接:http://pan.baidu.com/s/1cFqjQu SCALA专辑 Scala深入浅出经典视频 链接:http://pan ...

  2. WebDriver 随笔

    在webDriver中通过 driver.findElement进行定位元素时,往往是从页面的上到下依次寻找,根据该等位方式寻找到第一个元素. driver.findElement(By.id())有 ...

  3. ls -l 列表信息详解

    我们平时用ls -l 命令查看一个目录下的文件和子目录的详悉信息时,会得到一个详细的文件和目录名列表.这个列表包含了文件的属性,所属用户,所属组,创建时间,文件大小等等信息.这些信息到底是什么意思呢? ...

  4. (转)SQL Server 2005 中的计算字段

    在实际工作上遇到的问题: 在订单表中有某项商品是将“订购数量(Quantity)”乘以“单件价格(UnitCost)”等于该项商品的总价(Subtotal). 在数据表中有的列(以下皆改叫为“字段”) ...

  5. unable to connect to the virtual device Genymotion 神器启动问题

    截图: 解决方法:win7以上用户在桌面找到:网络--右键(属性)--更改适配器设置--VirtualBox Host-Only Network--属性--双击:Internet 协议版本4(TCP/ ...

  6. 菜鸟,大牛和教主三者的区别(转自hzwer)

    菜鸟,大牛和教主,三者的区别 对菜鸟来说题目有三种:会算法且能AC的,会算法但不能AC的,不会做的 对大牛来说题目有两种:会做的,不会做的 对教主来说题目有两种:能AC的,数据有错的 菜鸟提交WA了, ...

  7. 学点儿c#语言wpf开发

    首发:个人博客,更新&纠错&回复 visual studio 2015,界面越来越漂亮了. 比起swift和python啥的,还是c#外观上更像java,windows的界面编程,wp ...

  8. python字符串列表字典相互转换

    字符串转换成字典 json越来越流行,通过python获取到json格式的字符串后,可以通过eval函数转换成dict格式: >>> a='{"name":&qu ...

  9. 161124、Java 异常处理的误区和经验总结

    本文着重介绍了 Java 异常选择和使用中的一些误区,希望各位读者能够熟练掌握异常处理的一些注意点和原则,注意总结和归纳.只有处理好了异常,才能提升开发人员的基本素养,提高系统的健壮性,提升用户体验, ...

  10. WordPress博客网站fonts.useso加载慢解决办法

    WordPress博客网站fonts.useso加载慢解决办法 之前WordPress博客因为google字体库访问不了替换成360的useso,最近WordPress博客网站一直等待fonts.us ...