• jetty jndi数据源


    applicationContext.xml

    <?xml version="1.0" encoding="utf-8"?>
    <beans default-init-method="init" default-destroy-method="destroy"
        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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:mongo="http://www.springframework.org/schema/data/mongo"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
                               http://www.springframework.org/schema/beans/spring-beans.xsd 
                               http://www.springframework.org/schema/context 
                               http://www.springframework.org/schema/context/spring-context.xsd
                               http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
                               http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
                               http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
                               http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
           
           <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations" value="classpath:database.properties"/>
        </bean>
        
        <!-- jndi --> 
        <bean id="dataSourceMaster" class="org.springframework.jndi.JndiObjectFactoryBean"> 
            <property name="jndiName"> 
                <value>wms</value> 
            </property>
            <property name="resourceRef"> 
                <value>true</value> 
            </property>
        </bean>
        
        <bean id="dataSourceSlave" class="org.springframework.jndi.JndiObjectFactoryBean"> 
            <property name="jndiName"> 
                <value>wmsSlave</value> 
            </property>
            <property name="resourceRef"> 
                <value>true</value> 
            </property>
        </bean>
        
        <bean id="dataSource" class="com.yundaex.wms.config.DynamicDataSource" >  
            <property name="targetDataSources">  
                <map key-type="java.lang.String">  
                    <entry value-ref="dataSourceMaster" key="dataSourceMaster"></entry>  
                    <entry value-ref="dataSourceSlave" key="dataSourceSlave"></entry>  
                </map>  
            </property>  
            <property name="defaultTargetDataSource" ref="dataSourceMaster" >  
            </property>  
        </bean> 
        
        <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
            <property name="dataSource" ref="dataSource"></property>
        </bean>
        
        <bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
            <constructor-arg name="classicJdbcTemplate">
                <ref bean="jdbcTemplate"/>
            </constructor-arg>
        </bean>
        
        
        <bean id="dynamicDataSourceAspect" class="com.yundaex.wms.config.aop.DynamicDataSourceAspect"  />
    
        <aop:config>
              <aop:aspect ref="dynamicDataSourceAspect">
                 <aop:pointcut id="backMethod"   
                    expression="execution(public * com.yundaex.wms..CompleteInboundNoticeBackToQimenDao.query*(..))
                     || execution(public * com.yundaex.wms..InventoryCountReportToQimenDao.query*(..))
                      || execution(public * com.yundaex.wms..OrderProcessReportToQimenDao.query*(..))
                      || execution(public * com.yundaex.wms..OutboundNoticeConfirmBackToQimenDao.query*(..))
                       || execution(public * com.yundaex.wms..ReturnOrderBackToQimenDao.query*(..))
                        || execution(public * com.yundaex.wms..StockChangeReportToQimenDao.query*(..))
                      || execution(public * com.yundaex.wms..CompleteInboundNoticeBackToCainiaoDao.query*(..))
                     || execution(public * com.yundaex.wms..InventoryCountReportToCainiaoDao.query*(..))
                      || execution(public * com.yundaex.wms..OrderProcessReportToCainiaoDao.query*(..))
                      || execution(public * com.yundaex.wms..OutboundNoticeConfirmBackToCainiaoDao.query*(..))
                        "/>  
                 <aop:around method="aroundMethod"  pointcut-ref="backMethod"/>
              </aop:aspect>
        </aop:config>       
         
        <mvc:annotation-driven />
        <context:component-scan base-package="com.yundaex.wms" />
        <!-- 配置事务管理 -->
        <bean id="transactionManager"
            class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource">
                <ref bean="dataSource" />
            </property>
        </bean>
    
        <!-- 配置注解实现管理事务 -->
        <tx:annotation-driven transaction-manager="transactionManager"
            proxy-target-class="true" />
    </beans>

    WEB-INF文件夹下jetty-env.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
    <Configure class="org.eclipse.jetty.webapp.WebAppContext">
        <!-- 应用数据源 -->
        <New id="wmsMasterDataSource" class="org.eclipse.jetty.plus.jndi.Resource">
            <Arg>wms</Arg>
            <Arg>
                <New class="org.apache.commons.dbcp.BasicDataSource">
                    <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
                    <Set name="url">jdbc:mysql://10.19.105.161:3306/wms?useUnicode=true&amp;characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true</Set>
                    <Set name="username">ggs</Set>
                    <Set name="password">UGTVDYTXVSIN</Set>
                    <Set name="maxActive">500</Set>
                </New>
            </Arg>
        </New>
        <New id="wmsSlaveDataSource" class="org.eclipse.jetty.plus.jndi.Resource">
            <Arg>wmsSlave</Arg>
            <Arg>
               <New class="org.apache.commons.dbcp.BasicDataSource">
                    <Set name="driverClassName">com.mysql.jdbc.Driver</Set>
                    <Set name="url">jdbc:mysql://10.19.105.184:3306/wms?useUnicode=true&amp;characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true</Set>
                    <Set name="username">ggs</Set>
                    <Set name="password">ZPIOSVYLXMNI</Set>
                    <Set name="maxActive">500</Set>
                </New>
            </Arg>
        </New>
        <Set name="maxFormContentSize">2000000</Set>
    </Configure>
  • 相关阅读:
    TFS 2010 备份和恢复的完整解决方案
    PDC10 微软宣布TFS成功移植到云计算平台Windwos Azure
    基于Visual Studio 2010 进行敏捷/Scrum模式开发
    配置TFS服务器所需要的数据库权限
    TechEd2011 Session Visual Studio ALM项目管理 端到端的跟踪与控制
    微软云计算培训 (ethos)
    2007 Office System Driver: Data Connectivity Components
    Ajax post时需要注意的问题
    JQuyer $.post 与 $.ajax 访问WCF ajax service 时的问题
    ColorPicker js control
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/7866097.html
Copyright © 2020-2023  润新知