java.lang.IllegalStateException: Found multiple @SpringBootConfiguration annotated classes 出現這個異常是怎么回事呀
package?com.ep.email.hello;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.beans.factory.annotation.Value;
import?org.springframework.mail.SimpleMailMessage;
import?org.springframework.mail.javamail.JavaMailSender;
import?org.springframework.stereotype.Service;
@Service
public?class?MailService?{
????@Value("${spring.mail.username}")
????private?String?from;
????@Autowired
????private?JavaMailSender?mailSender;
????public?void?sayHello(){
????????System.out.println("hello?springboot!");
????}
????public?void?sendSimpleMail(String?to,String?subject,String?content){
????????SimpleMailMessage?message=new?SimpleMailMessage();
????????message.setTo(to);
????????message.setSubject(subject);
????????message.setText(content);
????????message.setFrom(from);
????????mailSender.send(message);
????}
}spring.mail.host=smtp.126.com [email protected] spring.mail.password=yourPassword126 spring.mail.default-encoding=UTF-8
pom.xml也配置了依賴mail
2019-09-09
你這個配置文件是客戶端授權碼,不要用他的那個要用自己郵箱的授權碼
我是因為測試類里面郵箱后綴忘寫了
2019-01-27
我也遇到了,因為 spring-boot-mail 項目是我們之前helloWorld直接復制過來的,所以會有之前生成的HelloWorldApplication.class 文件
解決方法:把?spring-boot-mail 這個項目 clean 一下,然后再compile 一下,其他不做任何修改,在去執行測試代碼即可
2018-09-24
我也遇到了,怎么解決?
2018-09-06
from?? 字段應該是final的