美文网首页工具使用指南
gradle的国内镜像完整设置(基于阿里云效)

gradle的国内镜像完整设置(基于阿里云效)

作者: JohnYuCN | 来源:发表于2021-07-14 18:49 被阅读0次

    1. 阿里云效服务:

    https://maven.aliyun.com/mvn/guide

    2. 配置

    
    buildscript { //此配置必须在plugins之前,用于引入社区的构建插件
        repositories {
            mavenLocal()
            maven {url 'https://maven.aliyun.com/repository/central'}
            maven {url 'https://maven.aliyun.com/repository/public'}
            maven {url 'https://maven.aliyun.com/repository/google'}
            maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
            maven {url 'https://maven.aliyun.com/repository/spring'}
            maven {url 'https://maven.aliyun.com/repository/spring-plugin'}
            maven {url 'https://maven.aliyun.com/repository/apache-snapshots'}
            mavenCentral()
            jcenter()
            google()
        }
    }
    
    plugins {
        id 'java' //java 核心插件
        id 'org.springframework.boot' version '2.4.2' //springboot社区插件
    }
    //allProjects { 如果是父项目
    repositories {
        mavenLocal()
        maven {url 'https://maven.aliyun.com/repository/central'}
        maven {url 'https://maven.aliyun.com/repository/public'}
        maven {url 'https://maven.aliyun.com/repository/google'}
        maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven {url 'https://maven.aliyun.com/repository/spring'}
        maven {url 'https://maven.aliyun.com/repository/spring-plugin'}
        maven {url 'https://maven.aliyun.com/repository/apache-snapshots'}
        mavenCentral()
        jcenter()
        google()
    }
    //}
    

    可在命令行,直接使用 ./gradlew dependencies进行依赖的引入

    3. springboot插件

    完整的包为:

    org.springframework.boot:spring-boot-gradle-plugin:2.4.2
    

    配置相当于maven中如下配置:

        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>2.4.2.RELEASE</version>
                    <configuration>
                        <fork>true</fork>
                        <addResources>true</addResources>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    

    相关文章

      网友评论

        本文标题:gradle的国内镜像完整设置(基于阿里云效)

        本文链接:https://www.haomeiwen.com/subject/sjtupltx.html