您的位置:首页 > 编程语言 > Java开发

springboot gradle打包,以及部署

2018-03-30 16:48 543 查看

找到这两个东西Gradle Tasks 下面有自己的Gradle项目,打开build找到clear,如果控制台显示success,在双击build下面的build等待打成jar包,如果springboot是2.0 需要将所有的配置指向application.yml,  在项目下面的目录下面打开build里面的libs里面的jar就是打好的jar包,通过shell连接服务器,放在下面还要将application.yml文件放到下面,通过java -jar xxxx.jar --spring.config.location=application.yml 先看前端是否可以启动,如果启动了按ctrl+c 退出,在后台启动 nohup java -jar xxxx.jar --spring.config.location=application.yml &   启动项目   通过ps -ef | grep java 查看是否启动,   如果关闭执行  kill -9 线程   杀死进程
java -jar rental-0.0.1.jar --spring.config.location=application.yml rental-0.0.1
 java -jar rental-0.0.1.jar --spring.config.location=application.yml &

build.gradle:
buildscript {
ext {
springBootVersion = '1.5.10.RELEASE'

jarName = project.name  
    mainClassName = 'com.ly.ApiApplication'  

}
repositories {
mavenCentral()

}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")

}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.ly'
version = '0.0.1'
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava,compileTestJava,javadoc]*.options*.encoding = 'UTF-8'

repositories {
maven {url 'http://172.18.115.187:8081/repository/maven-releases/'}
mavenCentral()
}

springBoot {
    executable = true
}

dependencies {

//compile('org.springframework.cloud:spring-cloud-starter-config')
//compile("org.springframework.retry:spring-retry")
compile group: 'org.springframework.boot',name: 'spring-boot-starter-actuator'
compile group: 'org.springframework.boot',name: 'spring-boot-starter-security'
   // compile('org.springframework.cloud:spring-cloud-starter-bus-amqp')
//compile('org.springframework.cloud:spring-cloud-starter-stream-rabbit')

//compile('org.springframework.cloud:spring-cloud-starter-hystrix')
compile("org.mybatis.generator:mybatis-generator-core:1.3.2")

compile('com.ly.cloud:boot-common-config:0.0.10')
compile('com.ly.cloud:ly-rpc-starter:0.0.7')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.cloud:spring-cloud-starter-eureka')
compile('org.springframework.cloud:spring-cloud-starter-feign')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1')
compile("org.springframework.boot:spring-boot-starter-aop")
compile("io.springfox:springfox-swagger2:2.7.0")
compile("io.springfox:springfox-swagger-ui:2.7.0")
compile("com.alibaba:fastjson:1.2.33")
compile("org.apache.commons:commons-lang3:3.5")
compile("commons-beanutils:commons-beanutils:1.9.3")
compile("com.google.guava:guava:21.0")
compile group: 'com.alibaba', name: 'druid', version: '1.1.6'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.45'
compile("org.apache.commons:commons-dbcp2:2.1.1")
compile group: 'commons-io', name: 'commons-io', version: '2.6'

//compile('org.springframework.cloud:spring-cloud-starter-sleuth')
//compile('org.springframework.cloud:spring-cloud-sleuth-zipkin')

//compile('org.springframework.boot:spring-boot-starter-data-mongodb')
//compile('org.springframework.boot:spring-boot-starter-data-redis')

//compile('org.springframework.boot:spring-boot-starter-data-mongodb-reactive')
//compile('org.springframework.boot:spring-boot-starter-webflux')

//testCompile('org.springframework.boot:spring-boot-starter-test')

//compile('com.ly.boot:ly-websocket-starter:0.0.5')

}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:Edgware.SR1"
    }
}

jar.manifest.attributes 'Main-Class': mainClassName  
jar.baseName = jarName 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: