Maven 上有多个 JavaMail 的库。到底用哪个呢?
[b]一、问题:[/b]
如果下载过时的库,会有与 javaee 中的库冲突的问题。
[b]二、结论:[/b]
使用这个: https://mvnrepository.com/artifact/com.sun.mail/javax.mail
[b]三、说明:[/b]
[b]JavaMail API from Maven[/b]
[quote]
I am trying to upgrade to latest Java Mail utility.
From
to (my Intention)
But I don't find 1.5.1 for mail artifact,
but I can see
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.mail vs javax.mail?
[/quote]
[quote]
The Maven coordinates changed some time ago to be compatible with the scheme described [url=https://glassfish.java.net/wiki-archive/Maven%20Versioning%20Rules.html]here[/url].
The new coordinates are [url=https://java.net/projects/javamail/pages/Home]here[/url].
[b]In short:[/b]
- The groupId [i][color=blue]javax.mail[/color][/i] is no longer used for the implementation.
- There is a new artifact at [i][color=blue]javax.mail:javax.mail-api[/color][/i].
It provides the [i][color=green]javax.mail-api.jar[/color][/i] file. This contains the JavaMail API definitions only, suitable for compiling against.
- [i][color=blue]com.sun.mail:javax.mail[/color][/i] contains the [i][color=green]javax.mail.jar[/color][/i] file, the JavaMail reference implementation jar file,
including the SMTP, IMAP, and POP3 protocol providers.
[b]So, you should:[/b]
- either use [i][color=blue]com.sun.mail:javax.mail[/color][/i] for compilation and packaging/deploy;
- or use [i][color=blue]javax.mail:javax.mail-api[/color][/i] for compilation and
then deploy the [i][color=blue]com.sun.mail:javax.mail[/color][/i] jar where appropriate (e.g., your Tomcat lib).
[/quote]
引用:
http://stackoverflow.com/a/22021656/2893073
https://java.net/projects/javamail/pages/Home
-
转载请注明
原文出处:http://lixh1986.iteye.com/blog/2323537
-
[b]一、问题:[/b]
如果下载过时的库,会有与 javaee 中的库冲突的问题。
[b]二、结论:[/b]
使用这个: https://mvnrepository.com/artifact/com.sun.mail/javax.mail
<!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.6</version>
</dependency>
[b]三、说明:[/b]
[b]JavaMail API from Maven[/b]
[quote]
I am trying to upgrade to latest Java Mail utility.
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,
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.mail vs javax.mail?
[/quote]
[quote]
The Maven coordinates changed some time ago to be compatible with the scheme described [url=https://glassfish.java.net/wiki-archive/Maven%20Versioning%20Rules.html]here[/url].
The new coordinates are [url=https://java.net/projects/javamail/pages/Home]here[/url].
[b]In short:[/b]
- The groupId [i][color=blue]javax.mail[/color][/i] is no longer used for the implementation.
- There is a new artifact at [i][color=blue]javax.mail:javax.mail-api[/color][/i].
It provides the [i][color=green]javax.mail-api.jar[/color][/i] file. This contains the JavaMail API definitions only, suitable for compiling against.
- [i][color=blue]com.sun.mail:javax.mail[/color][/i] contains the [i][color=green]javax.mail.jar[/color][/i] file, the JavaMail reference implementation jar file,
including the SMTP, IMAP, and POP3 protocol providers.
[b]So, you should:[/b]
- either use [i][color=blue]com.sun.mail:javax.mail[/color][/i] for compilation and packaging/deploy;
- or use [i][color=blue]javax.mail:javax.mail-api[/color][/i] for compilation and
then deploy the [i][color=blue]com.sun.mail:javax.mail[/color][/i] jar where appropriate (e.g., your Tomcat lib).
[/quote]
引用:
http://stackoverflow.com/a/22021656/2893073
https://java.net/projects/javamail/pages/Home
-
转载请注明
原文出处:http://lixh1986.iteye.com/blog/2323537
-
当使用过时的JavaMail库时,可能会与JavaEE中的库发生冲突。推荐使用Maven仓库中的com.sun.mail:javax.mail版本,以避免冲突。javax.mail-api提供了API定义,适合编译,而com.sun.mail:javax.mail包含了实现,包括SMTP、IMAP和POP3协议提供者。在编译和部署时,应选择合适的方式使用这两个依赖。
918

被折叠的 条评论
为什么被折叠?



