What is the difference between javax.mail
and javax.mail-api
?
I found those from maven repository.
When should each be used?
The software package comes with javax.mail-api
but I could not get it work, so I downloaded javax.mail
.
javax.mail-api
只包含接口, javax.mail
包含实现。
When libraries such as the Java Mail API are not published by their authors to Maven Central or other public repository, it's possible that different parties upload them, publishing it with conflicting groupId
. It's probably the case for those two you're seeing.
This artifact appears to contain the latest version of all you need to work with the mail api.
AFAIK from experience and looking at maven central ...
When javax.mail: mail is bundled in a 'war' and is also in tomcat 'lib' one gets this error:
java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
Similarly, javax.mail: javax-mail-api contains a Session class and is more than just interfaces. When it is missing one gets this error:
java.lang.NoClassDefFoundError: javax/mail/Authenticator
com.sun.mail: javax-mail is something sun/oracle specific.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.