Jakarta.mail.Provider: com.sun.mail.imap.IMAPProvider не является подтипомJAVA

Программисты JAVA общаются здесь
Anonymous
Jakarta.mail.Provider: com.sun.mail.imap.IMAPProvider не является подтипом

Сообщение Anonymous »

Я новичок в Springboot и Java. Я пытаюсь отправить электронное письмо из своей учетной записи Gmail через Spring Boot. До сих пор мне удавалось запускать код после всех конфигураций. Но бросает

Код: Выделить всё

jakarta.mail.Provider: com.sun.mail.imap.IMAPProvider not a subtype
При вызове метода отправки MailSender.

Код: Выделить всё

@Service
@EnableAutoConfiguration
public class EmailService {

@Autowired
private MailSender mailSender;

public void sendEmail(String to, String subject, String text) {
try{
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(to);
message.setSubject(subject);
message.setText(text);
mailSender.send(message);
} catch(Exception e){
System.out.println(e.getMessage());
}
}
application.properties

Код: Выделить всё

    spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=mygmailaccount
spring.mail.password=password
spring.mail.properties.mail.smtp.auth = true
spring.mail.properties.mail.smtp.starttls.enable = true
# Other properties
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
build.gradle

Код: Выделить всё

 implementation 'org.springframework.boot:spring-boot-starter-mail'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//implementation group: 'com.sun.mail', name: 'javax.mail', version: '1.6.2'
implementation group: 'com.sun.mail', name: 'jakarta.mail', version: '1.6.7'
Все перепробовал. Все еще не могу это исправить. Заранее спасибо.

Подробнее здесь: https://stackoverflow.com/questions/775 ... -a-subtype

Вернуться в «JAVA»