我正在 API 中发送 GET 请求(基于 JAX-WS,当前在 Eclipse 的 tomcat 服务器上运行),该请求应该使用 Gmail 发送电子邮件。 我遇到以下异常:
org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger
我做了什么?
将 javax.mail 依赖项添加到 pom.xml
<dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>1.6.0</version> <scope>test</scope> </dependency>
添加了 javax.mail-1.6.0.jar 到构建路径
- 将 javax.mail-1.6.0.jar 复制到
C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext
以上均未解决问题,
请指教,
谢谢!
最佳答案
根据mvnrepository.com你所需要的就是这个
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.0</version>
</dependency>
添加到您的 pom.xml
此外,在对 pom.xml 进行更改后,右键单击您的项目并运行 Maven clean、maven install 和 maven update 项目。
关于java.lang.NoClassDefFoundError : com/sun/mail/util/MailLogger while trying to send e-mail from JAX-WS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46506858/