gradle测试与线上打包
首先,第一反应理所当然的是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测试与线上打包的更多相关文章
- robot framework 测试/预发/线上环境快捷切换
通常情况下布署的三套环境:测试.预发及线上环境.调试或者辅助验证测试时,切环境改变量甚是麻烦.这些变量包括但不限于:一些url信息,数据库信息,预置用户信息等. 切换环境方法一:使用变量文件,通过判断 ...
- HBase工程师线上工作经验总结----HBase常见问题及分析
阅读本文可以带着下面问题:1.HBase遇到问题,可以从几方面解决问题?2.HBase个别请求为什么很慢?你认为是什么原因?3.客户端读写请求为什么大量出错?该从哪方面来分析?4.大量服务端excep ...
- (转)HBase工程师线上工作经验总结----HBase常见问题及分析
阅读本文可以带着下面问题:1.HBase遇到问题,可以从几方面解决问题?2.HBase个别请求为什么很慢?你认为是什么原因?3.客户端读写请求为什么大量出错?该从哪方面来分析?4.大量服务端excep ...
- 微软官方网站线上兼容测试平台-Browser screenshots
前端开发时最不想做的就是在不同浏览器.平台和分辨率测试网页显示效果,通常这会浮现许多问题,尤其浏览器版本就可能让显示成效完全不同,也只好尽力维持让每一种设备都能正常浏览网页.修改到完全没有问题必须投入 ...
- rsync实现负载均衡集群文件同步,搭建线上测试部署环境
闲来无事,搭建一个负载均衡集群,至于负载均衡集群搭建过程,找时间写下.这次主要写集群之间的文件同步,以及线上测试环境的搭建. 笔者看过很多公司都没有线上测试环境,真是崩溃了,不造怎么确保线上线下环境一 ...
- 使用tcpcopy拷贝线上流量压测测试环境
tcpcopy项目地址:https://github.com/session-replay-tools/tcpcopy 作者地址:http://blog.csdn.net/wangbin579 1:环 ...
- 使用tcpcopy导入线上流量进行功能和压力测试
- 假设我们要上线一个两年内不会宕机的先进架构.在上线前,免不了单元测试,功能测试,还有使用ab,webbench等等进行压力测试. 但这些步骤非生产环境下正式用户的行为.或许你会想到灰度上线,但毕竟 ...
- 使用tcpcopy复制线上流量进行测试
使用tcpcopy复制线上流量进行测试 online server 线上服务所在机器 10.136.11.4 部署tcpcopy sudo /usr/local/tcpcopy/sbin/tcpcop ...
- vue webkit-box-orient: vertical打包线上不显示
emmm……觉得不科学啊,写了几个vue的网站,限制超出行数省略号.结果发现放到线上,全都瓦特了.反复检查本地跑起来没错,代码没少,偏偏在线上的时候就是缺了vue -webkit-box-orient ...
随机推荐
- Duanxx的C++学习 : 数字转换String
下面是这两个数字转换String道路.件:sstream string num2str1(unsigned int num) { stringstream ss; ss<<num; ret ...
- 汉高澳大利亚sinox2014电影播放flash最好的办法是安装游戏windows文本firefox
事实上,韩澳sinox本身是没有原生flashplayer,无论怎么捣鼓,它们是从adobe弄linux要么windows版本号flashplayer,它不停地拨弄linux版本号flashplaye ...
- (大数据工程师学习路径)第一步 Linux 基础入门----文件系统操作与磁盘管理
介绍 本节的文件系统操作的内容十分简单,只会包含几个命令的几个参数的讲解,但掌握这些也将对你在学习后续其他内容的过程中有极大帮助. 因为本课程的定位为入门基础,尽快上手,故没有打算涉及太多理论内容,前 ...
- Python基本语法[二],python入门到精通[四] (转)
写在前面 python你不去认识它,可能没什么,一旦你认识了它,你就会爱上它 回到顶部 v正文开始:Python基本语法 1.定义常量: 之所以上篇博客介绍了定义变量没有一起介绍定义常量,是因为Pyt ...
- linux awk命令详细使用方法
简单介绍 awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部 ...
- C++ Primer 学习笔记_29_STL实践与分析(3) --操作步骤集装箱(下一个)
STL实践与分析 --顺序容器的操作(下) 六.訪问元素 假设容器非空,那么容器类型的front和back成员将返回容器的第一个和最后一个元素的引用. [与begin和end的对照:] 1)begin ...
- UVALive 4730 Kingdom +段树和支票托收
主题链接:点击打开链接 题意见白书P248 思路: 先把读入的y值都扩大2倍变成整数 然后离散化一下 用线段树来维护y轴 区间上每一个点的 城市数量和联通块数量. 然后用并查集维护每一个联通块及联通块 ...
- Spring4 SpringMVC Hibernate4 Freemaker 集成示例
变更更正(2014-05-30 13:47:22):一些IDE在web.xml我们会报告这个错误: cvc-complex-type.2.4.a: Invalid content was found ...
- sicily 1007 To and Fro (基地称号)
链接:http://soj.me/show_problem.php?pid=1007 Description Mo and Larry have devised a way of encrypting ...
- 运用TWaver 3D 矢量图形处理能力
的确,提起TWaver,大家想到的首先是"电信拓扑图组件".事实上.因为其灵活的MVC架构.矢量化设计.方便定制等特点.TWaver能够做的还有非常多.比如房地产行业常见到的&qu ...