【Gradle-5】Gradle常用命令与参数

news2024/9/21 18:33:27

1、前言

Gradle的命令有很多,熟悉常用命令之后,在日常开发中,不仅可以提升效率,也可以辅助我们快速定位并解决编译问题;而且某些情况下命令行(CLI)与按钮执行的编译结果是不一样的,比如构建时要传参(-P),所以就单拎出来一篇讲解,希望对你有帮助~

1、Gradle命令

1.1、gradlew

Gradle执行命令行主要用到的是Gradle Wrapper,关于Gradle Wrapper的介绍,在前文(【Gradle-2】一文搞懂Gradle配置)中有介绍,这里不再赘述。

所以我们常用的./gradlew(Mac),gradlew即Gradle Wrapper的简写。

Gradle Wrapper工作流:

再来看下gradlew的脚本内容

#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
##  Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> (.*)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname "$PRG"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
    echo "$*"
}

die () {
    echo
    echo "$*"
    echo
    exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
  CYGWIN* )
    cygwin=true
    ;;
  Darwin* )
    darwin=true
    ;;
  MINGW* )
    msys=true
    ;;
  NONSTOP* )
    nonstop=true
    ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
    else
        JAVACMD="$JAVA_HOME/bin/java"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
    MAX_FD_LIMIT=`ulimit -H -n`
    if [ $? -eq 0 ] ; then
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
            MAX_FD="$MAX_FD_LIMIT"
        fi
        ulimit -n $MAX_FD
        if [ $? -ne 0 ] ; then
            warn "Could not set maximum file descriptor limit: $MAX_FD"
        fi
    else
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
    fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
    GRADLE_OPTS="$GRADLE_OPTS "-Xdock:name=$APP_NAME" "-Xdock:icon=$APP_HOME/media/gradle.icns""
fi

# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

    JAVACMD=`cygpath --unix "$JAVACMD"`

    # We build the pattern for arguments to be converted via cygpath
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
    SEP=""
    for dir in $ROOTDIRSRAW ; do
        ROOTDIRS="$ROOTDIRS$SEP$dir"
        SEP="|"
    done
    OURCYGPATTERN="(^($ROOTDIRS))"
    # Add a user-defined pattern to the cygpath arguments
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
    fi
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    i=0
    for arg in "$@" ; do
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option

        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
        else
            eval `echo args$i`=""$arg""
        fi
        i=`expr $i + 1`
    done
    case $i in
        0) set -- ;;
        1) set -- "$args0" ;;
        2) set -- "$args0" "$args1" ;;
        3) set -- "$args0" "$args1" "$args2" ;;
        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
    esac
fi

# Escape application args
save () {
    for i do printf %s\n "$i" | sed "s/'/'\\''/g;1s/^/'/;$s/$/' \\/" ; done
    echo " "
}
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS ""-Dorg.gradle.appname=$APP_BASE_NAME"" -classpath ""$CLASSPATH"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

exec "$JAVACMD" "$@"
复制代码

代码量不多,gradlew主要干了几件事:

  1. 获取电脑系统内核的信息,JRE环境信息等;
  2. 设置classpath路径;
  3. 执行java命令工具,调用gradle jar包的class文件;

1.2、命令大全

当我们想知道一个工具有哪些命令的时候,最简单直接的方式就是使用help命令查看支持哪些,然后从中找到我们想要的。

执行:

 ./gradlew --help
复制代码

输出:

USAGE: gradlew [option...] [task...]

-?, -h, --help                     Shows this help message.
-a, --no-rebuild                   Do not rebuild project dependencies.
-b, --build-file                   Specify the build file. [deprecated]
--build-cache                      Enables the Gradle build cache. Gradle will try to reuse outputs from previous builds.
-c, --settings-file                Specify the settings file. [deprecated]
--configuration-cache              Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds. [incubating]
--configuration-cache-problems     Configures how the configuration cache handles problems (fail or warn). Defaults to fail. [incubating]
--configure-on-demand              Configure necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds. [incubating]
--console                          Specifies which type of console output to generate. Values are 'plain', 'auto' (default), 'rich' or 'verbose'.
--continue                         Continue task execution after a task failure.
-D, --system-prop                  Set system property of the JVM (e.g. -Dmyprop=myvalue).
-d, --debug                        Log in debug mode (includes normal stacktrace).
--daemon                           Uses the Gradle daemon to run the build. Starts the daemon if not running.
--export-keys                      Exports the public keys used for dependency verification.
-F, --dependency-verification      Configures the dependency verification mode. Values are 'strict', 'lenient' or 'off'.
--foreground                       Starts the Gradle daemon in the foreground.
-g, --gradle-user-home             Specifies the Gradle user home directory. Defaults to ~/.gradle
-I, --init-script                  Specify an initialization script.
-i, --info                         Set log level to info.
--include-build                    Include the specified build in the composite.
-M, --write-verification-metadata  Generates checksums for dependencies used in the project (comma-separated list)
-m, --dry-run                      Run the builds with all task actions disabled.
--max-workers                      Configure the number of concurrent workers Gradle is allowed to use.
--no-build-cache                   Disables the Gradle build cache.
--no-configuration-cache           Disables the configuration cache. [incubating]
--no-configure-on-demand           Disables the use of configuration on demand. [incubating]
--no-daemon                        Do not use the Gradle daemon to run the build. Useful occasionally if you have configured Gradle to always run with the daemon by default.
--no-parallel                      Disables parallel execution to build projects.
--no-scan                          Disables the creation of a build scan. For more information about build scans, please visit https://gradle.com/build-scans.
--no-watch-fs                      Disables watching the file system.
--offline                          Execute the build without accessing network resources.
-P, --project-prop                 Set project property for the build script (e.g. -Pmyprop=myvalue).
-p, --project-dir                  Specifies the start directory for Gradle. Defaults to current directory.
--parallel                         Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.
--priority                         Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Values are 'normal' (default) or 'low'
--profile                          Profile build execution time and generates a report in the <build_dir>/reports/profile directory.
--project-cache-dir                Specify the project-specific cache directory. Defaults to .gradle in the root project directory.
-q, --quiet                        Log errors only.
--refresh-dependencies             Refresh the state of dependencies.
--refresh-keys                     Refresh the public keys used for dependency verification.
--rerun-tasks                      Ignore previously cached task results.
-S, --full-stacktrace              Print out the full (very verbose) stacktrace for all exceptions.
-s, --stacktrace                   Print out the stacktrace for all exceptions.
--scan                             Creates a build scan. Gradle will emit a warning if the build scan plugin has not been applied. (https://gradle.com/build-scans)
--status                           Shows status of running and recently stopped Gradle daemon(s).
--stop                             Stops the Gradle daemon if it is running.
-t, --continuous                   Enables continuous build. Gradle does not exit and will re-execute tasks when task file inputs change.
--update-locks                     Perform a partial update of the dependency lock, letting passed in module notations change version. [incubating]
-v, --version                      Print version info.
-w, --warn                         Set log level to warn.
--warning-mode                     Specifies which mode of warnings to generate. Values are 'all', 'fail', 'summary'(default) or 'none'
--watch-fs                         Enables watching the file system for changes, allowing data about the file system to be re-used for the next build.
--write-locks                      Persists dependency resolution for locked configurations, ignoring existing locking information if it exists
-x, --exclude-task                 Specify a task to be excluded from execution.
复制代码

简写:

./gradlew -?
// or
./gradlew -h
复制代码

可以看到上面的输出已经列出来了很多命令,可能有些见过有些没见过,下面将把常用的提炼出来讲解,并进行分类。

1.3、命令结构

gradle [taskName...] [--option-name...]
复制代码

多个任务用空格分隔。

2、Gradle相关

2.1、查看Gradle版本

常见的查看Gradle版本有两种方式。

第一种是直接在gradle>wrapper>gradle-wrapper.properties文件下查看distributionUrl所使用的gradle版本下载地址:

distributionUrl=https://services.gradle.org/distributions/gradle-7.4-bin.zip
复制代码

这里的distributionUrl即表示当前所用的gradle版本为7.4。

第二种就是使用命令行的方式查看当前版本。

执行:

 ./gradlew -version
// or
./gradlew -v
复制代码

输出:

------------------------------------------------------------
Gradle 7.4
------------------------------------------------------------

Build time:   2022-02-08 09:58:38 UTC
Revision:     f0d9291c04b90b59445041eaa75b2ee744162586

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11 (Oracle Corporation 11+28)
OS:           Mac OS X 10.16 x86_64
复制代码

2.2、升级Gradle

常见的升级Gradle有3种方式。

第一种,先手动修改wrapper.properties文件下distributionUrl指向的版本,再手动修改Android Gradle Plugin(AGP)版本,然后重新sync。

第二种,打开file>Project Structure修改AGP和Gradle的版本,然后apply。

第三种,用命令行的方式(官方推荐,不过跟着AS一起升也是可以的):

./gradlew wrapper --gradle-version 7.5.1
复制代码

3、编译命令

3.1、检查依赖并编译打包

./gradlew build
复制代码

3.2、编译并打出Debug包

./gradlew assembleDebug
复制代码

3.3、编译打出Debug包并安装

./gradlew installDebug
复制代码

3.4、编译并打出Release包

./gradlew assembleRelease
复制代码

3.5、编译打出Release包并安装

./gradlew installRelease
复制代码

3.6、Debug/Release编译并打印日志

./gradlew assembleDebug --info
// or
./gradlew assembleRelease --info
复制代码

4、清除命令

清除构建目录下的产物。

./gradlew clean
复制代码

等同于Build->Clean Project。

5、卸载命令

5.1、卸载Debug/Release安装包

./gradlew uninstallDebug
// or
./gradlew uninstallRelease
复制代码

输出:

Uninstalling com.yechaoa.gradlex (from app:debug) from device 'Pixel_5_API_31(AVD) - 12' (emulator-5554).
Uninstalled com.yechaoa.gradlex from 1 device.
复制代码

5.2、adb卸载

在Android Studio中执行是直接卸载的当前项目安装包,如果是adb执行则需要指定包名

adb uninstall com.yechaoa.gradlex  
复制代码

6、调试命令

调试命令在定位编译问题的时候非常有用。

当我们遇到编译错误的时候,经常会看到这个提示:

* Try:
> Run gradle tasks to get a list of available tasks.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
复制代码

6.1、编译并打印堆栈日志

./gradlew assembleDebug --stacktrace
// or
./gradlew assembleDebug -s
复制代码

详细版:

./gradlew assembleDebug --full-stacktrace
// or
./gradlew assembleDebug -S
复制代码

6.2、日志级别

有时候构建日志会有很多,看到的可能不全,甚至不是真正的编译问题,而构建日志又不能像logcat那样可以可视化的筛选,这个时候就需要用日志级别来筛选一下。

-q,--quiet
仅记录错误。

-w,--warn
将日志级别设置为警告。

-i,--info
将日志级别设置为信息。

-d,--debug
调试模式(包括正常的stacktrace)。
复制代码

示例:

./gradlew assembleDebug -w
复制代码

7、任务相关

7.1、查看主要Task

./gradlew tasks
复制代码

7.2、查看所有Task

./gradlew tasks --all
复制代码

7.3、执行Task

./gradlew taskName
// or
./gradlew :moduleName:taskName
复制代码

同时,可在AS右侧工具类Gradle中查看项目及module的Task,并可以点击执行对应Task。

8、查看依赖

编译有很多问题都是依赖导致的错误,查看依赖能帮我们快速定位问题所在。

8.1、查看项目根目录下的依赖

./gradlew dependencies
复制代码

8.2、查看app模块下的依赖

./gradlew app:dependencies
复制代码

8.3、查看依赖输出到文件

./gradlew app:dependencies > dependencies.txt
复制代码

示例:

9、性能相关

9.1、离线编译

./gradlew assembleDebug --offline
复制代码

9.2、构建缓存

./gradlew assembleDebug --build-cache // 开启

./gradlew assembleDebug --no-build-cache // 不开启
复制代码

9.3、配置缓存

./gradlew assembleDebug --configuration-cache // 开启

./gradlew assembleDebug --no-configuration-cache // 不开启
复制代码

9.4、并行构建

./gradlew assembleDebug --parallel // 开启

./gradlew assembleDebug --no-parallel // 不开启
复制代码

以上9.1-9.4的配置也都可以在gradle.properties中配置。

示例:

#并行编译
org.gradle.parallel=true

#构建缓存
org.gradle.caching=true
复制代码

9.5、编译并输出性能报告

./gradlew assembleDebug --profile
复制代码

性能报告位于构建项目的GradleX/build/reports/profile/路径下

See the profiling report at: file:///Users/yechao/AndroidStudioProjects/GradleX/build/reports/profile/profile-2022-11-29-23-13-29.html
复制代码

输出的是html文件,用浏览器打开:

9.6、编译并输出更详细性能报告

./gradlew assembleDebug --scan
复制代码

首次执行需要邮箱验证,授权即可,完事之后即可打开链接,scan报告内容比profile更加详细。

10、动态传参

再来介绍一个比较常用的传参属性,--project-prop,我们一般常用-P表示,用来设置根项目的项目属性。

10.1、获取参数

示例:

 ./gradlew assembleDebug -PisTest=true 
复制代码

这里我们用-P传了一个isTest字段,并赋值为true

那在代码里如何获取这个参数呢?然后在build.gradle中编写如下代码:

if (hasProperty("isTest")){
    println("---hasProperty isTest yes")
}else {
    println("---hasProperty isTest no")
}
复制代码

我们可以用hasProperty来获取命令行(CLI)的参数,module或者插件也可以这么获取:

project.property('isTest')
复制代码

然后我们用上面的命令编译看下输出:

➜  GradleX git:(master) ✗ ./gradlew assembleDebug -PisTest=true 
---Gradle:开始初始化了
---Gradle:settingsEvaluated Settings对象评估完毕
---Gradle:projectsLoaded 准备加载Project对象了

> Configure project :
---Gradle:Projec beforeEvaluate Project开始评估,对象是 = GradleX
---hasProperty isTest yes //   --- 看这里 ---
---Gradle:Projec afterEvaluate Project评估完毕,对象是 = GradleX

> Configure project :app
---Gradle:buildFinished 构建结束了
复制代码

可以看到已经打印出来了。

还没完,获取到参数是不错,但是还没获取到参数的值。

10.2、获取参数值

我们可以用getProperty()来获取:

if (hasProperty("isTest")) {
    println("---hasProperty isTest yes")
    if (Boolean.valueOf(getProperty('isTest'))) {
        println("---isTest true")
    } else {
        println("---isTest false")
    }
} else {
    println("---hasProperty isTest no")
}
复制代码

注意,getProperty('isTest')这里要用单引号,另外命令行里面的参数值都是对象,还需要基本数据类型转换一下,即Boolean.valueOf(getProperty('isTest'))

10.3、自定义操作

ok,现在我们就可以针对获取的参数去做一些自定义的操作了,比如修改我们的依赖。

app>build.gradle:

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'

    if (project.hasProperty("isTest")) {
        println("---hasProperty isTest yes")
        if (Boolean.valueOf(getProperty('isTest'))) {
            println("---isTest true")

            implementation 'com.yechaoa.gradlex.devtools:devtools:1.1.1'

        } else {
            println("---isTest false")

            implementation 'com.yechaoa.gradlex.devtools:devtools:2.2.2'
        }
    } else {
        println("---hasProperty isTest no")
    }

    testImplementation 'junit:junit:4.13.2'
}
复制代码

这里举例,在isTest=true的时候依赖了devtools 1.1.1版本,isTest=false时依赖了devtools 2.2.2版本。

除了dependencies里面的依赖之外,Plugin、Task之类的也可以通过动态传参的方式去做自定义操作。

11、总结

本文介绍了Gradle Command-Line Interface(CLI)相关的知识,像调试命令、查看依赖、性能相关、动态传参这些,在定位问题、提升效率的时候还是非常有用的,希望能给你带来收获。(别忘了三连啊喂~)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/57825.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

大学生环保主题网页制作 环境网页设计模板 学生静态网页作业成品 dreamweaver保护地球环境HTML网站制作

&#x1f380; 精彩专栏推荐&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb; ✍️ 作者简介: 一个热爱把逻辑思维转变为代码的技术博主 &#x1f482; 作者主页: 【主页——&#x1f680;获取更多优质源码】 &#x1f393; web前端期末大作业…

【电商项目实战】上传头像(详细篇)

&#x1f341;博客主页&#xff1a;&#x1f449;不会压弯的小飞侠 ✨欢迎关注&#xff1a;&#x1f449;点赞&#x1f44d;收藏⭐留言✒ ✨系列专栏&#xff1a;&#x1f449;SpringBoot电商项目实战 ✨学习社区&#xff1a; &#x1f449;不会压弯的小飞侠 ✨知足上进&#x…

【Spring源码系列】Bean生命周期-实例化前

这里写目录标题前言一、实例化前 - InstantiationAwareBeanPostProcessor介绍InstantiationAwareBeanPostProcessor实例化前作用InstantiationAwareBeanPostProcessor实例化前代码案例二、实例化前 - 源码分析声明关键点源代码解读前言 在Bean的生命周期中&#xff0c;‘实例化…

Python还是很迷茫的小伙伴进来,教你用图秒懂Python

哈喽&#xff0c;大家好呀&#xff01;今天为大家带来12张图解python&#xff0c;让你们轻松学会了解python。 1.Python 解释器&#xff1a; Python数据结构&#xff1a;变量与运算符&#xff1a;Python 流程控制&#xff1a;Python 文件处理&#xff1a;python 输入输出&…

(三)Vue之模板语法

文章目录插值语法指令语法Vue学习目录上一篇&#xff1a;&#xff08;二&#xff09;初识Vue 下一篇&#xff1a;&#xff08;四&#xff09;Vue之数据绑定 Vue模板语法有2大类&#xff1a; 1.插值语法2.指令语法 插值语法 功能&#xff1a;用于解析标签体内容。 写法&…

lombok入门

目录 lombok概述 lombok安装 Getter、Setter ToString EqualsAndHashCode NotNull 生成构造方法相关注解 Data、Builder Log Cleanup、SneakyThrows lombok概述 以前的Java项目中&#xff0c;充斥着太多不友好的代码&#xff1a;POJO的getter/setter/toString/构造方…

Python迭代器和生成器

在Python中&#xff0c;很多对象都是可以通过for语句来直接遍历的&#xff0c;例如list、string、dict等等&#xff0c;这些对象都可以被称为可迭代对象。至于说哪些对象是可以被迭代访问的&#xff0c;就要了解一下迭代器相关的知识了。 迭代器 迭代器对象要求支持迭代器协议…

cpu设计和实现(总结篇)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 学习cpu&#xff0c;主要还是因为自己对它的原理和实现还有很多不明白、不清楚的地方&#xff0c;本着追根溯源的精神&#xff0c;正好借助于veril…

项目接入腾讯云短信服务SMS实现向用户发送手机验证码

1、自述 早在18年的时候&#xff0c;我就在项目中使用过阿里云的短信服务&#xff0c;现在我上阿里云短信控制台看&#xff0c;还能看到当时创建的短信签名&#xff0c;如下图所示。 出于某种原因&#xff0c;我现在想重新申请一个新的签名&#xff0c;却审批失败了&#xf…

HashMap和Hashtable的详细区别

HashMap和Hashtable的详细区别 一、简述&#xff1a; 1.安全性 Hashtable是线程安全&#xff0c;HashMap是非线程安全。HashMap的性能会高于Hashtable&#xff0c;我们平时使用时若无特殊需求建议使用HashMap&#xff0c;在多线程环境下若使用HashMap需要使用Collections.sy…

MyBatisPlus的使用入门

一、简介 官网&#xff1a;http://mp.baomidou.com/ 参考教程&#xff1a;http://mp.baomidou.com/guide/ MyBatis-Plus&#xff08;简称 MP&#xff09;是一个 MyBatis 的增强工具&#xff0c;在 MyBatis 的基础上只做增强不做改变&#xff0c;为简化开发、提高效率而生。 二、…

(ICLR-2019)DARTS:可微分架构搜索

DARTS&#xff1a;可微分架构搜索 paper题目&#xff1a;DARTS: DIFFERENTIABLE ARCHITECTURE SEARCH paper是CMU发表在ICLR 2019的工作 paper链接&#xff1a;地址 ABSTRACT 本文通过以可微分的方式制定任务来解决架构搜索的可扩展性挑战。与传统的在离散的、不可微分的搜索空…

【Android App】实战项目之使用OpenCV人脸识别实现找人功能(附源码和演示 超详细)

需要全部代码请点赞关注收藏后评论区留言私信~~~ 人脸识别自古有之&#xff0c;每当官府要捉拿某人时&#xff0c;便在城墙贴出通缉告示并附上那人的肖像。只是该办法依赖人们的回忆与主观判断&#xff0c;指认结果多有出入&#xff0c;算不上什么先进。 如今利用监控摄像头结合…

E3--FPGA实现LVDS收发实例和原理2022-12-03

1.什么是LVDS 一个新东西来的时候&#xff0c;人们总是希望能够宏观的定性的认识它。一个问题是&#xff0c;手机上用的“软件”该如何定义呢&#xff1f;来自百度百科的定义是&#xff0c;软件是指一系列按照特定顺序组织的计算机数据和指令的集合&#xff0c;如果你是非专业…

【Android App】给App集成WebRTC实现视频发送和接受实战(附源码和演示 超详细)

需要源码请点赞关注收藏后评论区留言私信~~~ 一、引入WebRTC开源库 WebRTC开源库的集成步骤如下&#xff1a; &#xff08;1&#xff09;给App模块的build.gradle添加WebRTC的依赖库配置&#xff1b; &#xff08;2&#xff09;App得申请录音和相机权限&#xff0c;还得申请…

[附源码]计算机毕业设计springboot自行车租赁管理系统

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

K-means聚类算法及Python代码实现

K-means聚类算法&#xff08;事先数据并没有类别之分&#xff01;所有的数据都是一样的&#xff09; 1、概述 K-means算法是集简单和经典于一身的基于距离的聚类算法 采用距离作为相似性的评价指标&#xff0c;即认为两个对象的距离越近&#xff0c;其相似度就越大。 该算法…

享元设计模式

一、享元模式 1、定义 享元模式&#xff08;Flyweight Pattern&#xff09;又称作轻量级模式&#xff0c;是指提供减少对象数量从而改善应用所需的对象结构的方式。其宗旨是共享细粒度的对象&#xff0c;将多个对同一对象的访问集中起来&#xff0c;不必为每个访问者都创建一个…

C++智能指针shared_ptr用法

目录shared_ptr功能介绍shared_ptr提供的接口shared_ptr初始化shared_ptr管理指针的构造和析构shared_ptr获取原始指针shared_ptr的线程安全shared_ptr应用之enable_shared_from_this写在前面的总结&#xff1a;一个shared_ptr对象管理一个指针&#xff08;new T&#xff0c;在…

TCP/IP五层协议栈(3)

1.网络层 1.1.IP协议 IP协议格式:报头数据 4位版本 :IP协议的版本号.当前只有两个取值,4和6(0100 0110).( 这里讨论IPv4 )4位首部长度 :IP报头和TCP类似,都是可变的,带有选项.8位TOS :只有4位有效,那四位TOS分别表示( 最小延时,最大吞吐量,最高可靠性,最小成本 )(同一时刻只能…