About two errors encountered while using JavaMail
1.java.lang.noclassdeffounderror:com/sun/mail/util/maillogger
2.java.lang.noclassdeffounderror:javax/mail/messagingexception
Pom.xml originally configured
<dependency>
<groupid >javax.mail </groupid >
<artifactid >javax.mail-api</ artifactid>
<version >1.5.1 </version >
<scope >test </scope >
</ Dependency>
Solution:
1.java.lang.noclassdeffounderror:com/sun/mail/util/maillogger
Maillogger--is part of the JavaMail, included in the Java EE environment, but not included in the Java SE environment, the big reason for this error is to test the sending of messages in the SE environment JAVAX.MAIL-API is only suitable for compiling, but if you really want to run the code, you must fully implement JavaMail can use <groupid>com.sun.mail</groupid><artifactid >javax.mail</artifactId>
Reference: http://stackoverflow.com/questions/16807758/ Java-lang-noclassdeffounderror-com-sun-mail-util-maillogger-for-junit-test-case
Pom.xml modified to
<span style= "White-space:pre" > </span><dependency >
<groupid >com.sun.mail </ GroupId >
<artifactid >javax.mail </artifactid >
<version >1.5.4 </version >
</dependency >
Then a second error occurs 2.java.lang.noclassdeffounderror:javax/mail/messagingexception
is because you need to mail.jar this jar bag.
Reference: http://javahonk.com/java-lang-classnotfoundexception-javax-mail-messagingexception/
The final pom.xml revision was changed to
<dependency >
<groupid >javax.mail </groupid >
<artifactid >mail </artifactid >
<version >1.4.5 </version >
</dependency >
<dependency >
<groupid > Com.sun.mail </groupid >
<artifactid >javax.mail </artifactid >
<version >1.5.4 </ Version >
</dependency >