来自 Maven 的 JavaMail API
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22020533/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JavaMail API from Maven
提问by Kumar
I am trying to upgrade to latest Java Mail utility.
我正在尝试升级到最新的 Java 邮件实用程序。
From
从
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
to (my Intention)
到(我的意图)
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.1</version>
</dependency>
But I don't find 1.5.1 for mail artifact,
但是我没有找到 1.5.1 的邮件神器,
but I can see
但我能看到
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.1</version>
</dependency>
My Question is why group id changed and if I change the group id for 1.5.1 do I need to change all my mail implementation that is already present (package name change and any other stuff) and what is the difference between com.sun.mailvs javax.mail?
我的问题是为什么组 id 更改,如果我更改 1.5.1 的组 id,我是否需要更改已经存在的所有邮件实现(包名称更改和任何其他内容)以及com.sun.mailvs之间有什么区别javax.mail?
采纳答案by Bill Shannon
The Maven coordinates changed some time ago to be compatible with the scheme described here. The new coordinates are here.
Maven 坐标在一段时间前发生了变化,以与此处描述的方案兼容。新坐标在这里。
In short:
简而言之:
- The groupId
javax.mailis no longer used for the implementation. - There is a new artifact at
javax.mail:javax.mail-api. It provides thejavax.mail-api.jarfile. This contains the JavaMail API definitions only, suitable for compiling against. com.sun.mail:javax.mailcontains thejavax.mail.jarfile, the JavaMail reference implementation jar file, including the SMTP, IMAP, and POP3 protocol providers.
- groupId
javax.mail不再用于实现。 - 有一个新的神器
javax.mail:javax.mail-api。它提供javax.mail-api.jar文件。这仅包含 JavaMail API 定义,适用于编译。 com.sun.mail:javax.mail包含javax.mail.jar文件,JavaMail 参考实现 jar 文件,包括 SMTP、IMAP 和 POP3 协议提供程序。
So, you should either use com.sun.mail:javax.mailfor compilation and packaging/deploy, or use javax.mail:javax.mail-apifor compilation and then deploy the com.sun.mail:javax.mailjar where appropriate (e.g., your Tomcat lib).
因此,您应该com.sun.mail:javax.mail用于编译和打包/部署,或者javax.mail:javax.mail-api用于编译然后com.sun.mail:javax.mail在适当的地方部署jar(例如,您的 Tomcat 库)。

