We may be in the use of JavaMail following exception:
1 Exception in thread "main" java.lang.NoSuchMethodError: com.sun.mail.util.TraceInputStream.<init>(Ljava/io/InputStream;Lcom/sun/mail/util/MailLogger;)V 2 at com.sun.mail.smtp.SMTPTransport.initStreams(SMTPTransport.java:2014) 3 at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1936) 4 at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654) 5 at javax.mail.Service.connect(Service.java:291) 6 at javax.mail.Service.connect(Service.java:172) 7 at javax.mail.Service.connect(Service.java:192)
The anomaly is caused by the conflict jar package, when sending the message that we need to introduce in the pom file manually javax.mail package at this time if the package is also included in the other of the jar when the abnormality occurs, we only Also included in the need to find the maven javax.mail packet jar on the list, as shown:
Then only need to exclude the corresponding jar dependent local javax.mail bag problem is solved
. 1 <Exclusions> 2 <-! Packet collision exclude mail, sending mail to avoid failure -> . 3 <Exclusion> . 4 <the groupId> the javax.mail </ the groupId> . 5 <the artifactId> mailapi </ the artifactId> . 6 </ Exclusion> . 7 </ Exclusions>