首页 文章 精选 留言 我的

精选列表

搜索[上传图片],共10009篇文章
优秀的个人博客,低调大师

Gradle学习之部署上传项目

原先在公司做项目时,写了一个简单的基于gradle部署项目的脚本,今天翻出来记录一下 一、build.gradle buildscript { ext { env = System.getProperty("env") ?: "test" jvmArgs = "-server -Xms128m -Xmx128m -XX:NewRatio=4 -XX:SurvivorRatio=16 -XX:MaxTenuringThreshold=15 -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+ExplicitGCInvokesConcurrent -XX:+DoEscapeAnalysis -XX:-HeapDumpOnOutOfMemoryError" if (env == "prod") { jvmArgs = "-server -Xms2g -Xmx2g -XX:NewRatio=4 -XX:SurvivorRatio=16 -XX:MaxTenuringThreshold=15 -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+ExplicitGCInvokesConcurrent -XX:+DoEscapeAnalysis -XX:-HeapDumpOnOutOfMemoryError" } userHome = System.getProperty("user.home") osName = System.getProperty("os.name") } repositories { jcenter() } dependencies { classpath 'org.hidetake:gradle-ssh-plugin:2.7.0' classpath 'co.tomlee.gradle.plugins:gradle-thrift-plugin:0.0.6' } } allprojects { apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'org.hidetake.ssh' group = 'com.mwee.information.core' version = '1.0-SNAPSHOT' ssh.settings { timeoutSec = 60 knownHosts = allowAnyHosts } defaultTasks 'clean', 'copyPartDependencies' //排除Log4j依赖 configurations { compile.exclude module: 'slf4j-log4j12' compile.exclude module: 'org.apache.logging.log4j' compile.exclude module: 'log4j' all*.exclude group: 'org.apache.logging.log4j' all*.exclude group: 'log4j' } } subprojects { apply plugin: 'java' sourceCompatibility = 1.8 targetCompatibility = 1.8 repositories { mavenLocal() maven { url "http://114.80.88.52:9001/nexus/content/groups/public/" } } sourceSets { main { java { srcDirs = ['src/main/java'] } resources { srcDirs = ["src/main/resources", "src/main/profile/$env"] } } } dependencies { compile("org.codehaus.groovy:groovy-all:2.2.1") compile 'org.codehaus.groovy:groovy-backports-compat23:2.4.5' compile("org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE") compile("org.apache.commons:commons-lang3:3.4") compile("org.apache.commons:commons-collections4:4.1") compile "org.apache.commons:commons-pool2:2.4.2" compile group: 'com.alibaba', name: 'fastjson', version: '1.2.12' // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6' // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.6' compile group: 'org.aspectj', name: 'aspectjrt', version: '1.8.7' compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.7' compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.1' compile(group: 'org.mortbay.jetty', name: 'jetty', version: '6.1.26') compile group: 'org.projectlombok', name: 'lombok', version: '1.16.8' compile group: 'com.squareup.okhttp', name: 'okhttp', version: '2.7.5' compile group: 'com.google.guava', name: 'guava', version: '18.0' compile group: 'commons-lang', name: 'commons-lang', version: '2.6' compile group: 'com.jcraft', name: 'jsch', version: '0.1.53' testCompile group: 'junit', name: 'junit', version: '4.12' testCompile "org.springframework:spring-test:4.3.4.RELEASE" compile "javax.validation:validation-api:1.1.0.Final" compile "org.hibernate:hibernate-validator:5.2.4.Final" } //gradle utf-8 compile tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } task copyAllDependencies(type: Copy, dependsOn: jar) { description = "拷贝全部依赖的jar包" from configurations.runtime into 'build/libs' } task copyPartDependencies(type: Copy, dependsOn: jar) { description = "拷贝部分依赖的jar" from configurations.runtime into 'build/libs' doLast { file("build/libs").listFiles({ !it.name.endsWith("-SNAPSHOT.jar") } as FileFilter).each { it.delete() } } } } View Code 二、对应模块下的build.gradle def mainClass = "com.hzgj.information.rest.user.run.UserServiceProvider" def appHome = "/home/appsvr/apps/rest_user" def javaCommand = "nohup java $jvmArgs -Djava.ext.dirs=$appHome/libs -Denv=$env $mainClass >$appHome/shell.log 2>&1 &" def index = System.getProperty("index") def remote = remotes { test_0 { role 'test_0' host = '10.0.21.152' if (file("$userHome/.ssh/id_rsa").exists()) { user = 'appsvr' identity = file("$userHome/.ssh/id_rsa") } else { user = 'appsvr' password = 'xxx' } } test_1 { role 'test_1' host = '10.0.146.20' if (file("$userHome/.ssh/id_rsa").exists()) { user = 'appsvr' identity = file("$userHome/.ssh/id_rsa") } else { user = 'appsvr' password = 'xxx' } } home { role 'home' host = '192.168.109.130' user = 'appsvr' password = 'xxx' // identity = file('id_rsa') } } task deploy << { description = "拷贝jar包并启动java服务" def roles = remote.findAll { def currentEnv = index == null ? "$env" : "$env" + "_" + index it['roles'][0].toString().contains(currentEnv) } ssh.run { roles.each { def role = it['roles'][0].toString() session(remotes.role(role)) { try { execute("ls $appHome") } catch (Exception e) { println("#############目录[$appHome]不存在,将自动创建############") execute("mkdir -p $appHome") } finally { def r = '$1' def pid = execute("jps -l |grep '$mainClass' |awk \'{print $r}\'") if (pid) { execute("kill -9 $pid") } put from: 'build/libs', into: "$appHome" println("###############准备启动java服务[$javaCommand]####################") execute("$javaCommand") sleep(10000) pid = execute("jps -l |grep '$mainClass' |awk \'{print $r}\'") if (pid) { println("#####$mainClass [$pid] 启动成功...######") execute("rm -f $appHome/shell.log") } else { println("#$mainClass 启动失败...输出日志如下:#") execute("cat $appHome/shell.log") } } } } } } task stop << { def roles = remote.findAll { def currentEnv = index == null ? "$env" : "$env" + "_" + index it['roles'][0].toString().contains(currentEnv) } ssh.run { roles.each { session(remotes.role("$env")) { def r = '$1' def pid = execute("jps -l |grep '$mainClass' |awk \'{print $r}\'") if (pid) { execute("kill -9 $pid") } } } } } task start << { def roles = remote.findAll { def currentEnv = index == null ? "$env" : "$env" + "_" + index it['roles'][0].toString().contains(currentEnv) } ssh.run { roles.each { def role = it['roles'][0].toString() session(remotes.role(role)) { def r = '$1' def pid = execute("jps -l |grep '$mainClass' |awk \'{print $r}\'") if (pid) { execute("kill -9 $pid") } println("###############准备启动java服务[$javaCommand]####################") execute("$javaCommand") sleep(10000) pid = execute("jps -l |grep '$main Class' |awk \'{print $r}\'") if (pid) { println("#$mainClass [$pid] 启动成功...#") execute("rm -f $appHome/shell.log") } else { println("#$mainClass 启动失败...输出日志如下:#") execute("cat $appHome/shell.log") } } } } } View Code 三、使用方式 1.先运行gradle copyAll -x test 进行打包操作,该操作会将该模块所有的依赖的jar 2.进入到对应的模块下 运行gradle deploy -Denv=xxx -Dindex=xxx ,什么意思呢?-Denv代表哪一个环境 -Dindex指定该环境下哪个节点进行发布 3.gradle start -Denv=xxx -Dindex=xxx 运行当前环境下的应用

优秀的个人博客,低调大师

Eclipse上传代码到GitHub

平时工作学习中难免会在Github搜索一下开源的Android代码, Android系统本身的代码就是托管在GitHub上,如果平时随手做了一个Demo,托管在云盘感觉不入流,如果平时自己一时兴起写了一个小Demo,希望分享给大家,那么GitHub自然是我们代码托管的首选。Google本身推出的捆绑的Eclipse本身已经将Git打包在里面,对于我们提交Android代码来说已经减少了一个步骤,下面就来具体的看看怎么将代码托管到GitHub: 1.首先确认Eclipse版本如果不是从Google下载的版本,则需要去http://download.eclipse.org/egit/updates/下载软件: Eclipse→Help→Install New SoftWare 2.我本身使用的是捆绑版本的,如果是非捆绑跟我接下来的步骤大同小异,接下来就是去Window→Preferences中操作,如图: 3.点击那个Generate RSA Key,生成Key,等会直接在保存在GitHub上: 5.在GitHub上面直接新增一个SSH Key,值就是上图那个大的红框中的值: 6.右击一个新建的Android项目,Team→Share Project: 7.然后将项目代码用Git仓库: 8.右击项目Team→Commit: 8.右键Team→Remote->Push,URI就是GitHub自己仓库的地址: 9.选择主分支,最下面有Finish提交即可: 10.最终结果: 本文转自Fly_Elephant博客园博客,原文链接:http://www.cnblogs.com/xiaofeixiang/p/4121991.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册