我正在使用java mail api发送邮件但遇到以下错误..
no suitable method found for getInstance(java.util,Properties,java.net.Authenticator)
这是我在java中的代码片段。
Authenticator auth = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password.toCharArray());
}
};
Session session = Session.getInstance(properties, auth);
我在接下来的行中收到了上述错误。
Session session = Session.getInstance(properties, auth);
请帮帮我。 提前谢谢..
答案 0 :(得分:3)
问题是您已导入java.net.Authenticator
而不是javax.mail.Authenticator
。查看错误消息中指定的类型,然后查看Session.getInstance
文档中的参数类型。