diff --git a/src/main/java/ntou/auction/spring/NtouAuctionJavaApplication.java b/src/main/java/ntou/auction/spring/NtouAuctionJavaApplication.java index 4bedc9e..1f84206 100644 --- a/src/main/java/ntou/auction/spring/NtouAuctionJavaApplication.java +++ b/src/main/java/ntou/auction/spring/NtouAuctionJavaApplication.java @@ -6,12 +6,14 @@ import org.springframework.boot.autoconfigure.sql.init.SqlDataSourceScriptDatabaseInitializer; import org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties; import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import javax.sql.DataSource; @SpringBootApplication @EnableScheduling +@EnableAsync public class NtouAuctionJavaApplication { public static void main(String[] args) { diff --git a/src/main/java/ntou/auction/spring/mail/EmailService.java b/src/main/java/ntou/auction/spring/mail/EmailService.java index afa1752..964ecb7 100644 --- a/src/main/java/ntou/auction/spring/mail/EmailService.java +++ b/src/main/java/ntou/auction/spring/mail/EmailService.java @@ -10,6 +10,7 @@ import org.springframework.mail.MailException; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.MimeMessagePreparator; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import java.util.Date; @@ -26,6 +27,7 @@ public EmailService(JavaMailSender mailSender, UserService userService, AppConfi this.appConfig = appConfig; } + @Async public void sendMailBidSuccess(Long userId, Product product) { if (userService.get(userId).isEmpty()) { @@ -89,6 +91,7 @@ public void sendMailBidFailed(Long userId, Product product) { } } */ + @Async public void sendMailOrderEstablished(Long userId, Order order) { if (userService.get(userId).isEmpty() || userService.get(order.getSellerid()).isEmpty()) { @@ -139,6 +142,7 @@ public void sendMailOrderEstablished(Long userId, Order order) { } } + @Async public void sendMailOrderUpdate(Long userId, Order order) { if (userService.get(userId).isEmpty() || userService.get(order.getSellerid()).isEmpty()) {