JavaMail API and Tomcat 7 Implementation

2020-04-17 06:18发布

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.

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?

1条回答
Emotional °昔
2楼-- · 2020-04-17 06:46

JavaMail is a standard JSR 919

TomEE server has support for JavaMail.

The configuration is very easy and goes like this

  1. tomee already comes with apache-tomee-plus-1.6.0/lib/geronimo-javamail_1.4_mail-1.8.2.jar
  2. in tomee.xml (configured at $TOMEE/conf) you add an entry as described by Configuring JavaMail
  3. from inside your classes you can reference the mail session via @Resource like described at javax.mail.Session resource and smtp authentication
查看更多
登录 后发表回答