出现的问题
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.nowcoder.community.MailTests': Unsatisfied dependency expressed through field 'mailClient'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.nowcoder.util.MailClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
分析原因:
是这个 'com.nowcoder.community.MailTests'测试类 找不到'com.nowcoder.util.MailClient'这个类。
为什么会找不到呢,是因为这个类所在的包没有在 community这个包下,在util包下。正确的应该是util包在 community这个包下才行。
修改之后
输出结果;
第2个出现的问题,如果报错出现 503 ,说明这个邮箱配置的密码应该是 SMTP授权码,而不是自己的登录密码。