0
如何向SBT添加標準Java庫?例如,我的類依賴這些進口:使用SBT添加標準Java庫
[error] /Users/jacobus/scalaprojects/doxy/src/main/scala/EmailService.scala:6: expected class or object definition
[error] val props = new Properties();
這裏的源:如果我使用這些,例如
import javax.mail._
import javax.mail.internet._
import java.util.Properties
試圖與SBT編譯失敗
import java.util.Properties
import javax.mail._
import javax.mail.internet._
val props = new Properties();
props.put("mail.smtp.host", "localhost");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable","true");
props.put("mail.debug", "true");
val session = Session.getInstance(props);
val message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
message.setRecipients(Message.RecipientType.TO, "[email protected]");
message.setSubject("This is the Subject");
message.setText("This is the Message");
val transport = session.getTransport("smtp");
transport.connect("localhost","username","password")
Transport.send(message);
該錯誤似乎不是相對於導入,而是在類中缺少類/對象定義。可能是這種情況? – Nicolas 2012-02-27 10:09:13
我希望是的,但代碼在Idea中運行良好。我只是無法用SBT編譯它 – Jack 2012-02-27 10:16:39
在Twitter Finagle庫也依賴於javax之前,我已經遇到了這個問題,也可能不包含它。 – Jack 2012-02-27 10:18:45