gradle - Kotlin Gradle 使用依赖项
问题描述
我正在尝试org.apache.commons.net.*
使用 Gradle 和命令行在 Kotlin 中包含库。
在我的build.gradle.kts
文件的依赖项中,我写道:
compile 'commons-net:commons-net:3.6'
正如apache文档中所说,但它给了我一个奇怪的错误:
> Configure project :
e: D:\core\Confidential\Learn\Kotlin\build.gradle.kts:30:13: Too many characters
in a character literal ''commons-net:commons-net:3.6''
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\core\Confidential\Learn\Kotlin\build.gradle.kts' line: 30
* What went wrong:
Script compilation error:
Line 30: compile('commons-net:commons-net:3.6')
^ Too many characters in a character literal ''commons-ne
t:commons-net:3.6''
1 error
* Try:
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.
* Get more help at https://help.gradle.org
(我也试过compile 'commons-net:commons-net:3.6'
and compile group: 'commons-net', name: 'commons-net', version: '3.6'
)。
我对 Kotlin 完全陌生,在开始在 IDEA 上进行 Android 开发之前,我正在尝试熟悉它。
谢谢。
解决方案
就像在 Java 中一样,'
适用于字符文字,"
也适用于字符串文字。
你想要"commons-net:commons-net:3.6"
。
并且compile()
已弃用。使用implementation()
.
推荐阅读
- sql-server - 使用 Windows 身份验证和 SQL Server 数据库
- javascript - Css bootstrap glyphicon-calendar不显示日历
- python - SQL Server 旋转一列并保留其他列
- css - 仅将某些 li 元素设置为内联显示
- ssl - 具有 http 和 https 的 Envoy 代理 (v3 api)
- outlook-restapi - 有没有办法以编程方式接收所有通配符电子邮件?
- flutter - 为什么我在使用颤振相机时得到 CAMERA_ERROR (3)
- android - 试图通过 viewModel 访问资源
- performance - 一般来说,tomcat或直接geoserver哪个会更快?
- c# - 实体框架 - 保存前读取更新