我有以下服务,每次客户购买时都会发送电子邮件
@Component
public class EmailerService extends JavaMailSenderImpl {
public boolean sendEmail(String userFullName, String recipient, String subject, String content,String replyTo)
throws AddressException, MessagingException {
initJavaMailProps(replyTo);
Message message = new MimeMessage(getSession());
message.setFrom(new InternetAddress(senderEmailAddress));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(recipient));
message.setSubject(subject);
if (withGreeting())
content = "Dear " + userFullName + ",\n\n"+content;
if (withRegards())
content += "\n\nBest Regards, \n\nDNA G2 Support";
message.setText(content);
Transport.send(message);
return true;
}
在我的 XML 配置中,我有两个Spring profile
名为“正常”和“云”。现在我想添加一个新的配置文件让我们说“开发”并想在开发过程中“禁用”这个服务。这是因为在我的本地测试期间仍然发送了许多电子邮件。实现这一目标的最简单方法是什么?