BUG記錄:Gradle打包-沒有主清單屬性

Gradle-沒有主清單屬性(Gradle- no main manifest attribute)

解決方法:修改文件build.gradle,完成樣式

buildscript {
    ext{
        springBootVersion = '2.0.2.RELEASE'
        springCloudVersion = 'Finchley.RELEASE'
    }

    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}


group 'com.bf'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'

version = '1.0.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenLocal()
    maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

test {
    ignoreFailures = true
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.0'
    compile 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.0.0.RELEASE'

    compile 'org.apache.httpcomponents:httpclient:4.5.5'
    compile 'tk.mybatis:mapper-spring-boot-starter:2.0.0'
    
    compile 'io.springfox:springfox-swagger2:2.7.0'
    compile 'io.springfox:springfox-swagger-ui:2.7.0'

    compile 'net.sf.json-lib:json-lib:2.4:jdk15'
    compile 'com.alibaba:fastjson:1.2.62'

    testCompile 'org.springframework.boot:spring-boot-starter-test'
}

執行:gradle build -x test 命令
在這裏插入圖片描述

查看jar文件,出現紅色框裏內容表示成功
在這裏插入圖片描述

在本地jar包下打開cmd測試 ,執行命令java -jar #{jar包名}

在這裏插入圖片描述

跑起來,成功
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章