【发布时间】:2021-10-31 00:28:58
【问题描述】:
我正在尝试使用 Twilio 发送 SMS 消息。我已按照所有说明操作并设置了 JAVA_HOME 环境变量。当我运行程序时,我得到:
任务“:StockAlertClass:SMS.main()”执行失败。
进程 'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home/bin/java'' 以非零退出值 1 结束
-
尝试: 使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
-
例外情况是: org.gradle.api.tasks.TaskExecutionException:任务':StockAlertClass:SMS.main()'的执行失败。 引起:org.gradle.process.internal.ExecException:进程'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home/bin/java''以非零退出值1
我的java类是:
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
public class SMS {
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
public static final String ACCOUNT_SID = System.getenv("HiddenForPrivacy");
public static final String AUTH_TOKEN = System.getenv("HiddenForPrivacy");
public static void Message() {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message.creator(new PhoneNumber("+HiddenForPrivacy"),
new PhoneNumber("HiddenForPrivacy"),
"Test ").create();
System.out.println(message.getSid());
}
public static void main(String[] args) {
Message();
}
}
build.gradle 是:
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
mavenLocal()
}
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
dependencies {
compile 'org.slf4j:slf4j-simple:1.6.+'
compile 'com.sparkjava:spark-core:2.5.+'
implementation group: "com.twilio.sdk", name: "twilio", version: "8.21.0"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
// https://mvnrepository.com/artifact/com.twilio.sdk/twilio
runtimeOnly group: 'com.twilio.sdk', name: 'twilio', version: '8.21.0'
}
test {
useJUnitPlatform()
}
【问题讨论】: