完整的application.xml



    <beans profile="dev">
        <bean class="com.ningpai.util.CustomPropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/com/ningpai/web/config/dev/jdbc.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/es-hosts.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/redis.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/amq.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/config.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/kaQuan.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/zjlogin.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/kuaidi100.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/resource.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/czb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/hzb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/jlPay.propertiesvalue>
                list>
            property>
        bean>
    beans>
package com.ningpai.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * Created by Intellij Idea
 *
 * @auth hangzhou.team.rmitec
 * @company shanghai ruimin internet technology co.ltd
 * @date 2017/12/12
 */
public class CustomPropertyPlaceholderConfigurer extends org.springframework.beans.factory.config.PropertyPlaceholderConfigurer {

	private static Map<String, String> ctxPropertiesMap = new HashMap<String, String>();

	@Override
	protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,Properties props) throws BeansException {
		super.processProperties(beanFactoryToProcess, props);
		for (Object key : props.keySet()) {
			String keyStr = key.toString();
			String value = props.getProperty(keyStr);
			ctxPropertiesMap.put(keyStr, value);
		}
	}

	/**
	 * 读取配置
	 *
	 * @param name
	 * @return
	 */
	public static String getProperty(String name) {
		return ctxPropertiesMap.get(name);
	}
}

完整的application.xml



<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:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:redisson="http://redisson.org/schema/redisson"
    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/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/task  
						http://www.springframework.org/schema/task/spring-task-4.0.xsd
                        http://redisson.org/schema/redisson
                        http://redisson.org/schema/redisson/redisson.xsd
						">

	<import resource="spring-jcaptcha.xml" />
    <import resource="spring-plugin.xml" />
    
    <bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration">
        <property name="maxInactiveIntervalInSeconds" value="604800"/>
    bean>
    <bean class="org.springframework.session.web.http.DefaultCookieSerializer">
        <property name="cookieName" value="JSESSIONID"/>
    bean>
    


    
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
          init-method="init" 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="initialSize" value="50" />
        <property name="maxActive" value="200" />
        <property name="maxIdle" value="50" />
        <property name="minIdle" value="10" />
        
        <property name="testWhileIdle" value="true" />
        <property name="testOnBorrow" value="true" />
        <property name="testOnReturn" value="false" />
        <property name="validationQuery" value="select 1" />
        <property name="validationQueryTimeout" value="15" />
        <property name="connectionInitSqls" value="set names utf8mb4;"/>
        <property name="timeBetweenEvictionRunsMillis" value="20000" />
        <property name="numTestsPerEvictionRun" value="100" />
        
        <property name="filters" value="${druid.filters}" />
    bean>
    
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    bean>

    
    <bean id="txDefinitionNew" class="org.springframework.transaction.support.DefaultTransactionDefinition">
        <property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW" />
        <property name="isolationLevel" value="2">property>
    bean>
    <context:component-scan  base-package="com.ningpai,com.qianmi,com.zjfae"/>
    
    <tx:annotation-driven/>
	
    
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="configLocation"
        	value="classpath:/com/ningpai/web/mybatis/SqlMapConfig.xml" />
        <property name="dataSource" ref="dataSource" />
        <property name="mapperLocations">
            <array>
                <value>classpath*:com/qianmi/*/mapper/**/*.xmlvalue>
                <value>classpath*:com/ningpai/mybatis/mapper/DepositInfoMapper.xmlvalue>
                <value>classpath*:com/ningpai/mybatis/mapper/TradeInfoMapper.xmlvalue>
            array>
        property>
    bean>
    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg index="0" ref="sqlSessionFactory" />
    bean>
    
    <bean id="mappingJacksonHttpMessageConverter"
        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />

    
    <bean id="esClientManager" class="com.ningpai.searchplatform.client.ESClientManager" scope="singleton">
        <constructor-arg index="0" type="java.lang.String">
            <value>${es.hosts}value>
        constructor-arg>
        <constructor-arg index="1" type="java.lang.String" value="${es.cluster.name}"/>
    bean>

    
    
    <bean id="threadPool" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
        
        <property name="corePoolSize" value="20"/>
        
        <property name="maxPoolSize" value="50"/>
        
        <property name="queueCapacity" value="200"/>
        
        <property name="keepAliveSeconds" value="300"/>
        
        <property name="waitForTasksToCompleteOnShutdown" value="true"/>
    bean>

    <task:scheduled-tasks>
		<task:scheduled ref="RefundmentUtil" method="service" cron="0 0 12 * * ?" />
	task:scheduled-tasks>

    <bean id="redisAdapter" class="com.ningpai.redis.RedisAdapter" scope="singleton">bean>

    <bean id="redisProductCache" class="com.zjfae.goods.redis.RedisProductCache" scope="singleton">bean>

    <bean id="redisMarketingCache" class="com.qianmi.marketing.redis.RedisMarketingCache" scope="singleton">bean>

    <bean id="redisTopicCache" class="com.zjfae.topic.redis.RedisTopicCache" scope="singleton">bean>

		  <bean id="SpringApplicationContext" class="com.ningpai.common.util.ApplicationContextHelper">bean>


     <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
         <property name="maxIdle" value="${redis.maxIdle}" />
         <property name="maxTotal" value="${redis.maxActive}" />
         <property name="maxWaitMillis" value="${redis.maxWait}" />
         <property name="testOnBorrow" value="${redis.testOnBorrow}" />
     bean>

     <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
         p:host-name="${redis.host}" p:port="${redis.port}"  p:database="${redis.dbIndex}"  p:pool-config-ref="poolConfig"/>

     <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
         <property name="connectionFactory"   ref="connectionFactory" />
     bean>

    
    <redisson:client id="redissonClient">
        <redisson:single-server address="redis://${redis.host}:${redis.port}" />
    redisson:client>

     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource">property>
     bean>

        
        <bean id="wxClientCredential" class="com.ningpai.m.weixin.util.WxClientCredential" scope="singleton" />

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.ningpai.deposit.mapper,
        com.qianmi.marketing.dao,
        com.ningpai.marketing.dao.point,
        com.qianmi.coupon.mapper,
        com.qianmi.couponGroup.dao,
        com.qianmi.couponRedeem.dao,
        com.qianmi.newCustomerConfig.dao,
        com.qianmi.receive.dao,
        com.qianmi.promotioner.dao,
        com.ningpai.report.dao,
        com.ningpai.dict.dao,
        com.ningpai.commentResources.dao,
        com.ningpai.customer.dao.balance,
        com.ningpai.customer.dao.channelCustomerInfo,
        com.ningpai.customermerge.dao,
        com.ningpai.customerOption.dao,
        com.ningpai.privacyAgreement.dao,
        com.ningpai.system.dao.weixin,
        com.ningpai.system.dao.channelSet,
        com.ningpai.system.dao.outlet,
        com.ningpai.system.dao.common,
        com.zjfae.goods.dao,
        com.qianmi.site.common.dao,
        com.qianmi.marketing.groupon.dao,
        com.qianmi.invoice.dao,
        com.zjfae.flow.dao,
        com.zjfae.common.dao,
        com.zjfae.strategy.dao,
        com.zjfae.hop.dao,
        com.zjfae.jushuitan.dao,
        com.zjfae.nuonuo.dao,
        com.zjfae.report.dao,
        com.zjfae.share.dao,
        com.zjfae.goods.dao,
        com.zjfae.topic.dao,
        com.zjfae.order.dao
        com.ningpai.system.trans.dao,
        com.zjfae.white.dao,
        com.zjfae.vending.dao,
        com.ningpai.goods.dao.unexpress,
        com.ningpai.customer.dao.zjfae,
        com.ningpai.customer.dao.shareApply,
        com.zjfae.pay.dao,
        com.zjfae.page.dao,
        com.zjfae.domain.dao,
        com.zjfae.wxlogistics.dao,
        com.zjfae.log.dao,
        com.ningpai.goods.dao.erp,
        com.ningpai.marketing.dao.receiveRecord"/>

    bean>
    <import resource="classpath*:spring-amq.xml"/>
    <import resource="classpath*:spring-promotioner.xml"/>

    
    <beans profile="dev">
        <bean class="com.ningpai.util.CustomPropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/com/ningpai/web/config/dev/jdbc.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/es-hosts.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/redis.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/amq.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/config.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/kaQuan.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/zjlogin.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/kuaidi100.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/resource.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/czb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/hzb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/dev/jlPay.propertiesvalue>
                list>
            property>
        bean>
    beans>

    <beans profile="test">
        <bean class="com.ningpai.util.CustomPropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/com/ningpai/web/config/test/jdbc.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/es-hosts.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/redis.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/amq.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/config.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/kaQuan.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/zjlogin.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/kuaidi100.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/resource.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/czb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/hzb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/test/jlPay.propertiesvalue>
                list>
            property>
        bean>
    beans>

    <beans profile="uat">
        <bean class="com.ningpai.util.CustomPropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/com/ningpai/web/config/uat/jdbc.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/es-hosts.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/redis.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/amq.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/config.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/kaQuan.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/zjlogin.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/kuaidi100.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/resource.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/czb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/hzb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/uat/jlPay.propertiesvalue>
                list>
            property>
        bean>
    beans>

    <beans profile="prd">
        <bean class="com.ningpai.util.CustomPropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/com/ningpai/web/config/prd/jdbc.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/es-hosts.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/redis.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/amq.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/config.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/kaQuan.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/zjlogin.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/kuaidi100.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/resource.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/czb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/hzb.propertiesvalue>
                    <value>classpath:/com/ningpai/web/config/prd/jlPay.propertiesvalue>
                list>
            property>
        bean>
    beans>
beans>

你可能感兴趣的:(xml,java,mybatis)