I am new to Spring Boot. I have this emailprop.properties
in src/main/resource
:
//your private key
mail.smtp.dkim.privatekey=classpath:/emailproperties/private.key.der
But I am getting the error as
classpath:\email properties\private.key.der (The filename, directory name, or volume label syntax is incorrect)
How do I properly load this file?
Update-1
my java code is
dkimSigner = new DKIMSigner(emailProps.getProperty("mail.smtp.dkim.signingdomain"), emailProps.getProperty("mail.smtp.dkim.selector"), emailProps.getProperty("mail.smtp.dkim.privatekey"));
its working as
"D:\\WorkShop\\MyDemoProj\\EmailService\\src\\main\\resources\\private.key.der"
Instead ofemailProps.getProperty("mail.smtp.dkim.privatekey")
Update-2
i have tried java code is
String data = ""; ClassPathResource cpr = new ClassPathResource("private.key.der"); try { byte[] bdata = FileCopyUtils.copyToByteArray(cpr.getInputStream()); data = new String(bdata, StandardCharsets.UTF_8); } catch (IOException e) { e.printStackTrace(); } dkimSigner = new DKIMSigner(emailProps.getProperty("mail.smtp.dkim.signingdomain"), emailProps.getProperty("mail.smtp.dkim.selector"),data);
Error is :
java.io.FileNotFoundException: class path resource [classpath:private.key.der] cannot be resolved to URL because it does not exist
Tried Code is :
ClassPathResource resource = new ClassPathResource(emailProps.getProperty("mail.smtp.dkim.privatekey")); File file = resource.getFile(); String absolutePath = file.getAbsolutePath();
Still same error..
please update the answer..