首先,第一反应理所当然的是profile :

<?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:tx="http://www.springframework.org/schema/tx" 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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd "
default-lazy-init="true">
<description>Spring</description> <!--已经用注解实现了,请查看RedisConfig-->
<!--<import resource="classpath:applicationContext-redis.xml"/>-->
<!--<import resource="classpath:applicationContext-mongo.xml"/>-->
<!--已经修改为通过注解配置-->
<!--<context:component-scan base-package="*********" />--> <!--线上配置读写分离的时候用这个 start -->
<bean id="writeDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="driverClassName" value="${master.jdbc.driver}" />
<property name="url" value="${master.jdbc.url}" />
<property name="username" value="${master.jdbc.username}" />
<property name="password" value="${master.jdbc.password}" />
<property name="maxActive" value="${maxActive}" />
<property name="minIdle" value="${maxIdle}" />
</bean>
<bean id="readDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="driverClassName" value="${slave.jdbc.driver}" />
<property name="url" value="${slave.jdbc.url}" />
<property name="username" value="${slave.jdbc.username}" />
<property name="password" value="${slave.jdbc.password}" />
<property name="maxActive" value="${maxActive}" />
<property name="minIdle" value="${maxIdle}" />
</bean>
<bean id="dataSource" class="---------------------------------------Source" primary="true">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry key="write" value-ref="writeDataSource"/>
<entry key="read" value-ref="readDataSource"/>
</map>
</property>
<property name="defaultTargetDataSource" ref="writeDataSource"/>
</bean>
<!--线上配置读写分离的时候用这个 end --> <!-- 配置mybatis的sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描mappers.xml文件 ,要加上classpath:com/... -->
<property name="mapperLocations" value="classpath*:-----/**/*Mapper.xml"></property>
<!-- mybatis配置文件 -->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
</bean> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> <!-- 配置事务通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="checkLock*" propagation="REQUIRES_NEW" isolation="READ_COMMITTED" />
<tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="batch*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="new*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="add*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="create*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="insert*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="register*" propagation="REQUIRED" isolation="DEFAULT" />
<tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT" read-only="true" />
<tx:method name="find*" propagation="REQUIRED" isolation="DEFAULT" read-only="true" />
<tx:method name="select*" propagation="REQUIRED" isolation="DEFAULT" read-only="true" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice> <!-- aop事务配置 -->
<aop:config>
<aop:pointcut id="txPointcut" expression="execution(* *..*Service.*(..))" /><!-- (public * com.*.service..*.*(..))-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
</aop:config> <!-- 启用事务注释支持 -->
<tx:annotation-driven transaction-manager="transactionManager" /> <beans profile="production">
<context:property-placeholder location="classpath*:production/*"/>
<bean id="propertyConfigurer" class="---------------------------.EncryptablePropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:production/jdbc.properties</value>
<value>classpath:production/application.properties</value>
<value>classpath:production/readDBPath.properties</value>
<value>classpath:production/localswitch.properties</value>
<value>classpath:production/redisCache.properties</value>
</list>
</property>
</bean>
</beans>
<beans profile="test">
<context:property-placeholder location="classpath*:test/*"/>
<!-- 属性文件读入 -->
<bean id="propertyConfigurer-test" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:test/jdbc.properties</value>
<value>classpath:test/application.properties</value>
<value>classpath:test/readDBPath.properties</value>
<value>classpath:test/localswitch.properties</value>
<value>classpath:test/redisCache.properties</value>
</list>
</property>
</bean>
</beans>
</beans>

  然而,这个方法有点不太理想,因为似乎只能支持文本类型比如properties什么的,即使不用org.springframework.beans.factory.config.PropertyPlaceholderConfigurer,然后我们用的gradle,于是又有以下方法(使用gradle自定义打包命令):

  

group 'project'
version '1.0-SNAPSHOT' apply plugin: 'java'
apply plugin: 'maven' sourceCompatibility = 1.8
targetCompatibility = 1.8 repositories {
mavenLocal()
maven{
url 'http://192.168.1.-:8081/nexus/content/repositories/thirdparty/'
}
maven{
url 'http://192.168.1.-:8081/nexus/content/groups/public/'
}
} dependencies {
compile('---:spring-boot-dubbox-starter:0.0.1'){
exclude module: "slf4j-log4j12"
}
compile(
[group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.4.0.RELEASE'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version: '1.4.0.RELEASE'],
// [group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '1.4.0.RELEASE'],
project(":p2p-support"),
project(":p2p-api")
)
testCompile(
// [group: 'junit', name: 'junit', version: '4.11']
)
} jar {
baseName = '---'
version = '1.0-SNAPSHOT'
destinationDir=file("$buildDir/libs")
}
// 项目依赖包拷贝
task copyDependency(type : Copy){
from configurations.compile
into "$buildDir/output/dependency"
}
// 复制Dockerfile 文件
task copyDockerfile(type : Copy){
from("src/main/resources/docker/Dockerfile")
into "zip"
} def copyMainClass = copySpec{
from ("$buildDir/classes/main")
into "classes"
} def copyAllLib = copySpec{
from ("$buildDir/output/dependency")
into "lib"
} def copyConf = copySpec{
from (sourceSets.main.resources.srcDirs){
include "*.xml"
include "cert/**"
include "META-INF/**"
include "templates/**"
include "*.properties"
}
into "conf"
} def copyBin = copySpec{
from (sourceSets.main.resources.srcDirs){
include "bin/*.sh"
}
}
// 打包
task zipProject(type:Zip, dependsOn : [jar, copyDependency] ){
with copyAllLib
with copyMainClass
with copyConf
with copyBin
into baseName
destinationDir=file("zip")
} def copyProductionConf = copySpec{
from ("package/production"){
include "*.xml"
include "cert/**"
include "META-INF/**"
include "templates/**"
include "*.properties"
}
into "conf"
} // build product project
task zipProductProject(type:Zip, dependsOn : [jar, copyDependency] ){
with copyAllLib
with copyMainClass
with copyProductionConf
with copyBin
into baseName
destinationDir=file("zip")
} def copyTestConf = copySpec{
from ("package/test"){
include "*.xml"
include "cert/**"
include "META-INF/**"
include "templates/**"
include "*.properties"
}
into "conf"
} // build product project
task zipTestProject(type:Zip, dependsOn : [jar, copyDependency] ){
with copyAllLib
with copyMainClass
with copyTestConf
with copyBin
into baseName
destinationDir=file("zip")
}

项目结构:

gradle测试与线上打包的更多相关文章

  1. robot framework 测试/预发/线上环境快捷切换

    通常情况下布署的三套环境:测试.预发及线上环境.调试或者辅助验证测试时,切环境改变量甚是麻烦.这些变量包括但不限于:一些url信息,数据库信息,预置用户信息等. 切换环境方法一:使用变量文件,通过判断 ...

  2. HBase工程师线上工作经验总结----HBase常见问题及分析

    阅读本文可以带着下面问题:1.HBase遇到问题,可以从几方面解决问题?2.HBase个别请求为什么很慢?你认为是什么原因?3.客户端读写请求为什么大量出错?该从哪方面来分析?4.大量服务端excep ...

  3. (转)HBase工程师线上工作经验总结----HBase常见问题及分析

    阅读本文可以带着下面问题:1.HBase遇到问题,可以从几方面解决问题?2.HBase个别请求为什么很慢?你认为是什么原因?3.客户端读写请求为什么大量出错?该从哪方面来分析?4.大量服务端excep ...

  4. 微软官方网站线上兼容测试平台-Browser screenshots

    前端开发时最不想做的就是在不同浏览器.平台和分辨率测试网页显示效果,通常这会浮现许多问题,尤其浏览器版本就可能让显示成效完全不同,也只好尽力维持让每一种设备都能正常浏览网页.修改到完全没有问题必须投入 ...

  5. rsync实现负载均衡集群文件同步,搭建线上测试部署环境

    闲来无事,搭建一个负载均衡集群,至于负载均衡集群搭建过程,找时间写下.这次主要写集群之间的文件同步,以及线上测试环境的搭建. 笔者看过很多公司都没有线上测试环境,真是崩溃了,不造怎么确保线上线下环境一 ...

  6. 使用tcpcopy拷贝线上流量压测测试环境

    tcpcopy项目地址:https://github.com/session-replay-tools/tcpcopy 作者地址:http://blog.csdn.net/wangbin579 1:环 ...

  7. 使用tcpcopy导入线上流量进行功能和压力测试

    - 假设我们要上线一个两年内不会宕机的先进架构.在上线前,免不了单元测试,功能测试,还有使用ab,webbench等等进行压力测试. 但这些步骤非生产环境下正式用户的行为.或许你会想到灰度上线,但毕竟 ...

  8. 使用tcpcopy复制线上流量进行测试

    使用tcpcopy复制线上流量进行测试 online server 线上服务所在机器 10.136.11.4 部署tcpcopy sudo /usr/local/tcpcopy/sbin/tcpcop ...

  9. vue webkit-box-orient: vertical打包线上不显示

    emmm……觉得不科学啊,写了几个vue的网站,限制超出行数省略号.结果发现放到线上,全都瓦特了.反复检查本地跑起来没错,代码没少,偏偏在线上的时候就是缺了vue -webkit-box-orient ...

随机推荐

  1. ActionBarActivity: cannot be resolved to a type

    "the import android.support.v7 cannot be resolved  " or "ActionBarActivity: cannot be ...

  2. Upgrade Ver 4.3.x from 4.2.x

    级到遇到个小问题.解决细节记录例如以下. [gpadmin@wx60 ~]$ gpmigrator /usr/local/greenplum-db-4.2.7.2 /usr/local/greenpl ...

  3. 在CentOS 7上安装phpMyAdmin

    原文 在CentOS 7上安装phpMyAdmin phpMyAdmin是一款以PHP为基础,基于Web的MySQL/MariaDB数据库管理工具.虽然已经存在着一些诸如Adminer的轻量级数据库管 ...

  4. 图片 Base64码 转换

    import sun.misc.BASE64Decoder; private String getBase64Picture(String imgBase64Str) { FileOutputStre ...

  5. hdu Hat's Tea

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1288 去买茶,需要正好的钱才行,另外花的钱的个数最多  其实是一个简单的贪心问题,小的多取一点,多的少 ...

  6. Util

    Util最新代码更新说明   离上一篇又过去了一个月,时间比较紧,后续估计会更紧,所以这次将放出更多公共操作类及配套的CodeSmith模板,本篇将简要介绍新放出的重要功能,供有兴趣的同学参考. 重要 ...

  7. MongoDB详解学习历程

    MongoDB是一个基于分布式文件存储的数据库,它是介于关系数据库和非关系数据库之间的产品. MongoDB支持的数据结构非常松散,类似json的bjson格式,因此可以存储比较复杂的数据类型.Mon ...

  8. C#命令模式-设计模式学习

    命令模式(Command Pattern) 概述   在软件系统中,“行为请求者”与“行为实现者”通常呈现一种“紧耦合”.但在某些场合,比如要对行为进行“记录.撤销/重做.事务”等处理,这种无法抵御变 ...

  9. 它们的定义app.config中间section节点和在执行中使用

    如果现在我们需要在app.config一个节点的在下面的例子中,定义,我们需要如何进行操作? <configSections> <section name="integra ...

  10. FPGA笔记-阅读.dat文件

    阅读.dat图像文件 .dat文件是matlab生成的图像文件 initial begin // Initialize Inputs CLK = 0; RST = 1; IMAGE_DATA = 0; ...