嗨,我正在使用Maven,我正在尝试生成Excel,然后将其作为附件发送到NetBeans中的电子邮件中。我没有收到任何错误,但是在我的tomcat中,我收到了以下错误,我将非常感谢您的帮助或建议>
我的pom
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl -->
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<!-- End change plugin specific dependencies here -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.15</version>
<type>jar</type>
</dependency>
</dependencies>
错误
SEVERE [http-nio-443-exec-10] org.oo.project1.try1.execute null
java.lang.ClassCastException: javax.mail.util.ByteArrayDataSource cannot be cast to javax.sql.DataSource
at org.oo.project1.try1.sendMail(carexcel.java:282)
at org.oo.project1.try1.tryy(carexcel.java:240)
at org.oo.project1.try1.execute(carexcel.java:116)
答案 0 :(得分:3)
尝试将<scope>provided</scope>
添加到您的javax.mail依赖项中,然后重新启动并重新部署Tomcat。
答案 1 :(得分:0)
看起来您的代码已导入,使javax.sql.DataSource与javax.activation.DataSource混淆。