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 ...
随机推荐
- CodeIgniter连接数据库及快速入门
原文:CodeIgniter连接数据库及快速入门 一.数据库配置 CodeIgniter 有一个配置文件让你存放数据库连接值(username:用户名,password:密码,database nam ...
- android使用ffmpeg
cygwin上文编译文章. 在ffmpeg/arm添加的文件夹Android.mk 的主要目的是为了宣布动态库libs下一个 LOCAL_PATH:= $(call my-dir) include $ ...
- HDU 5281 Senior's Gun (贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5281 贪心题目,但是看看我的博客里边相关贪心的题解实在是少的可怜,这里就写出来供大家一起探讨. 题意还 ...
- View Component
View Component 在之前的MVC中,我们经常需要类似一种小部件的功能,通常我们都是使用Partial View来实现,因为MVC中没有类似Web Forms中的WebControl的功能. ...
- 乐视TV2015校园招聘A第二个大的发行量(of中国Academy科学大学站)
标题叙述性说明:鉴于阵列A,尺寸n,数组元素1至n数字.但是一些数字多次出现.有些数字不出现.请设计算法和程序,统计数据不会出现什么.什么号码多次出现.在O(n)时间复杂度,O(1)在完成它的空间复杂 ...
- Nutch之简介与安装
初学Nutch之简介与安装 初学Nutch之简介与安装 1.Nutch简介 Nutch是一个由Java实 现的,开放源代码(open-source)的web搜索引擎.主要用于收集网页数据,然后对其 ...
- yii 使用 mongodb 小工具 YiiMongoDbSuite
YiiMongoDbSuite下载链接: http://www.yiiframework.com/extension/yiimongodbsuite/ 如果你的yii和mongodb它已经建立了一个良 ...
- JS开发调试
开发调试工具 页面制作之开发调试工具(1) 开发工具介绍 开发工具一般分为两种类型:文本编辑器和集成开发环境(IDE) 常用的文本编辑器:Sublime Text.Notepad++.EditPl ...
- Socket 学习(三).5 UDP 的弱点
前面 讲到了,udp 传输文本的例子,发现 udp 确实 比tcp 高效一些,现在我用来传输文件,问题果然来了,结果发现 他不能一次 传输大于 64K的东西! 那么 我自然想到了 切包,多次发送,再合 ...
- 自动生成Makefile文件
主要的工具有autoscan, aclocal, autoheader, autoconfig,automake 1 .创建c源文件hello.c #include <stdio.h> i ...