|
| 1 | +package com.back.global.mail; |
| 2 | + |
| 3 | +import org.springframework.context.ApplicationContext; |
| 4 | +import org.springframework.mail.javamail.JavaMailSender; |
| 5 | +import org.springframework.web.bind.annotation.GetMapping; |
| 6 | +import org.springframework.web.bind.annotation.RestController; |
| 7 | + |
| 8 | +import java.util.Arrays; |
| 9 | + |
| 10 | +@RestController |
| 11 | +public class MailDebugController { |
| 12 | + |
| 13 | + private final ApplicationContext context; |
| 14 | + |
| 15 | + public MailDebugController(ApplicationContext context) { |
| 16 | + this.context = context; |
| 17 | + } |
| 18 | + |
| 19 | + @GetMapping("/debug/mail") |
| 20 | + public String debugMail() { |
| 21 | + StringBuilder sb = new StringBuilder(); |
| 22 | + |
| 23 | + // MailConfig 빈 확인 |
| 24 | + sb.append("MailConfig bean exists: ").append(context.containsBean("mailConfig")).append("\n"); |
| 25 | + |
| 26 | + // JavaMailSender 빈 확인 |
| 27 | + sb.append("JavaMailSender bean exists: ").append(context.containsBean("javaMailSender")).append("\n"); |
| 28 | + |
| 29 | + // 모든 Configuration 빈 확인 |
| 30 | + sb.append("\nAll Configuration beans:\n"); |
| 31 | + Arrays.stream(context.getBeanDefinitionNames()) |
| 32 | + .filter(name -> name.toLowerCase().contains("config")) |
| 33 | + .forEach(name -> sb.append("- ").append(name).append("\n")); |
| 34 | + |
| 35 | + // JavaMailSender 타입의 빈 확인 |
| 36 | + try { |
| 37 | + JavaMailSender mailSender = context.getBean(JavaMailSender.class); |
| 38 | + sb.append("\nJavaMailSender found: ").append(mailSender.getClass().getName()); |
| 39 | + } catch (Exception e) { |
| 40 | + sb.append("\nJavaMailSender NOT found: ").append(e.getMessage()); |
| 41 | + } |
| 42 | + |
| 43 | + return sb.toString(); |
| 44 | + } |
| 45 | +} |
0 commit comments