我有以下幾點:DataSource和ByteArrayDataSource不兼容?
InputStream imageStream = classLoader.getResourceAsStream("email/logo.png");
DataSource fds = new ByteArrayDataSource(IOUtils.toByteArray(imageStream), "image/png");
會拋出我的錯誤:我在做什麼錯在這裏
Error:(65, 30) java: incompatible types: javax.mail.util.ByteArrayDataSource cannot be converted to org.apache.poi.poifs.nio.DataSource
Error:(66, 44) java: no suitable constructor found for DataHandler(org.apache.poi.poifs.nio.DataSource) constructor javax.activation.DataHandler.DataHandler(javax.activation.DataSource) is not applicable (argument mismatch; org.apache.poi.poifs.nio.DataSource cannot be converted to javax.activation.DataSource) constructor javax.activation.DataHandler.DataHandler(java.net.URL) is not applicable (argument mismatch; org.apache.poi.poifs.nio.DataSource cannot be converted to java.net.URL)
?
我們不知道你在努力達到什麼目標,這很難幫助你。你確定你真的想要使用'org.apache.poi.poifs.nio.DataSource'嗎?也許你真的想'javax.activation.DataSource'來代替? –
@JonSkeet,就是這樣! – uksz