问题描述
有几个 Java EE API 就是这样存在的 - API(接口、域对象、枚举等,但没有做事情的实际类).API,如 JPA、JDBC 或 JTA.这些 API 必须有实现;对于 JPA,有像 Hibernate、MyBatis 或 TopLink 这样的实现.对于 JDBC,每个特定的 RDBMS 都有驱动程序.对于 JTA,有 Bitronix 和 Atomikos.
There are several Java EE APIs that exist as just that - APIs (interfaces, domain objects, enums, etc. but no actual classes that do stuff). APIs like JPA, JDBC or JTA. These APIs must then have implementations; for JPA there are impls like Hibernate, MyBatis or TopLink. For JDBC there are drivers for each specific RDBMS. For JTA there is Bitronix and Atomikos.
但是 JavaMail 呢?它只是一个API吗?如果是这样,它的一些常见实现是什么?如果我将我的 Java 应用程序(作为 WAR)部署到 Tomcat 7,那么这个实现来自哪里(特别是)?Tomcat 有自己的 JavaMail 实现吗?Tomcat 实现由哪些 JAR/包/类组成?
But what about JavaMail? Is it just an API? If so, what are some common implementations of it? If I deploy my Java app (as a WAR) to Tomcat 7, where does this implementation come from (specifically)? Does Tomcat have its own JavaMail impl? What JARs/packages/classes compose the Tomcat impl?
推荐答案
JavaMail 是一个标准的 JSR 919
JavaMail is a standard JSR 919
TomEE 服务器支持 JavaMail.
TomEE server has support for JavaMail.
配置很简单,就是这样
- tomee 已经带有
apache-tomee-plus-1.6.0/lib/geronimo-javamail_1.4_mail-1.8.2.jar
- 在
tomee.xml
(在$TOMEE/conf
中配置)中添加一个条目,如 配置 JavaMail - 在您的课程中,您可以通过
@Resource
引用邮件会话,如 javax.mail.Session 资源和 smtp 认证
- tomee already comes with
apache-tomee-plus-1.6.0/lib/geronimo-javamail_1.4_mail-1.8.2.jar
- in
tomee.xml
(configured at$TOMEE/conf
) you add an entry as described by Configuring JavaMail - from inside your classes you can reference the mail session via
@Resource
like described at javax.mail.Session resource and smtp authentication
这篇关于JavaMail API 和 Tomcat 7 实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!