gpt4 book ai didi

java - 线程 "main"com.google.apphosting.api.ApiProxy$CallNotFoundException : The API package 'mail' or call 'Send()' was not found 中的异常

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:29:28 26 4
gpt4 key购买 nike

我编写了一个使用 gmail 发送邮件的程序,如果我单独执行它,它工作正常,但是当我与 google appengine 集成时,它给我以下错误,

Exception in thread "main" com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'mail' or call 'Send()' was not found.
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:104)
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:56)
at com.google.appengine.api.mail.MailServiceImpl.doSend(MailServiceImpl.java:98)
at com.google.appengine.api.mail.MailServiceImpl.send(MailServiceImpl.java:34)
at com.google.appengine.api.mail.stdimpl.GMTransport.sendMessage(GMTransport.java:231)
at javax.mail.Transport.send(Transport.java:95)
at javax.mail.Transport.send(Transport.java:48)
at in.javadomain.PostMail.postMailMethod(PostMail.java:49)
at in.javadomain.PostMail.main(PostMail.java:20)

我确信没有集成错误或失误。我也已经添加了 javax.mail jar。

最佳答案

您需要正确设置测试环境,如下所示:

private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalMailServiceTestConfig());

@Before
public void setUp() {
helper.setUp();
}

@After
public void tearDown() {
helper.tearDown();
}

GAE 需要这些依赖项:

<properties>
<gae.version>1.9.17</gae.version>
</properties>
...
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>

关于java - 线程 "main"com.google.apphosting.api.ApiProxy$CallNotFoundException : The API package 'mail' or call 'Send()' was not found 中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17895442/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com