gradle配置maven仓库

Maven配置

  • 在gradle(kts)中配置maven:

    build.gradle.kts

//仓库配置
repositories {
    //mavenLocal { setUrl("file://${project.rootDir}/lib") }
    //首先去本地仓库找
    mavenLocal()
    //然后去阿里仓库找
    // build.gradle:
    // maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }

    // build.gradle.kts:
    maven { url = uri("https://repo.spring.io/release") }
    maven { url = uri("https://repo.spring.io/milestone") }
    maven { url = uri("https://plugins.gradle.org/m2/") }
    maven {
        isAllowInsecureProtocol = true
        setUrl("https://maven.aliyun.com/nexus/content/groups/public/")
    }
    maven {
        isAllowInsecureProtocol = true
        url = uri("https://maven.aliyun.com/repository/public") }
    maven {
        isAllowInsecureProtocol = true
        url = uri("https://maven.aliyun.com/repository/google") }
    maven {
        isAllowInsecureProtocol = true
        url = uri("https://maven.aliyun.com/repository/gradle-plugin") }
    maven {
        isAllowInsecureProtocol = true
        url = uri("https://maven.aliyun.com/repository/spring-plugin") }
    maven {
        isAllowInsecureProtocol = true
        url = uri("https://maven.aliyun.com/repository/apache-snapshots") }
    maven {
        isAllowInsecureProtocol = true
        url = uri("https://oss.jfrog.org/artifactory/oss-snapshot-local/") }
    google()
    jcenter()
    //最后从maven中央仓库找
    mavenCentral()
}
  • 在gradle(groovy)中配置maven:

    build.gradle

//仓库配置
repositories {
    //mavenLocal { setUrl("file://${project.rootDir}/lib") }
    //首先去本地仓库找
    mavenLocal()
    //然后去阿里仓库找
    // build.gradle.kts:
    //maven {
    //    isAllowInsecureProtocol = true
    //    setUrl("https://maven.aliyun.com/nexus/content/groups/public/")
    //}

    // build.gradle:
    maven { 
        setAllowInsecureProtocol(true)
        url "https://repo.spring.io/release" 
    }
    maven {
        setAllowInsecureProtocol(true)
        url "https://repo.spring.io/milestone"
    }
    maven {
        //isAllowInsecureProtocol = true
        setAllowInsecureProtocol(true)
        url "https://maven.aliyun.com/nexus/content/groups/public/"
    }
    maven {
        //isAllowInsecureProtocol = true
        setAllowInsecureProtocol(true)
        url "https://maven.aliyun.com/repository/public"
    }
    maven {
        //isAllowInsecureProtocol = true
        setAllowInsecureProtocol(true)
        url "https://maven.aliyun.com/repository/google" }
    maven {
        //isAllowInsecureProtocol = true
        setAllowInsecureProtocol(true)
        url "https://maven.aliyun.com/repository/gradle-plugin" }
    maven {
        //isAllowInsecureProtocol = true
        setAllowInsecureProtocol(true)
        url "https://maven.aliyun.com/repository/spring-plugin" }
    maven {
        //isAllowInsecureProtocol = true
        setAllowInsecureProtocol(true)
        url "https://maven.aliyun.com/repository/apache-snapshots" }
    maven {
        //isAllowInsecureProtocol = true
        setAllowInsecureProtocol(true)
        url "https://oss.jfrog.org/artifactory/oss-snapshot-local/" }
    google()
    jcenter()
    //最后从maven中央仓库找
    mavenCentral()
}

IDEA配置代码模板

  1. 打开配置(settigs/preference)

  2. 搜索live(找到live template)

  3. 找到kotlin、gradle,分别做如下配置
    maven代码模板

  4. 配置完毕后,在编辑器中输入“mreps”,弹出提示,回车(Enter)。
    使用示例

posted @ 2021-08-23 10:40  LANGKYE#  阅读(5448)  评论(0编辑  收藏  举报