简体   繁体   中英

How to provide the path of trust store file?

I have a java maven project where my truststore file(abc.pem) is inside the resources folder.

How to give the path for this?

System.setProperty("javax.net.ssl.trustStore", path);

You can get the path of a file in src/main/resources with getClass().getResource("/path/to/file") .

For example, if resources contains a single file called "file.txt", the code getClass().getResource("/file.txt") will return the absolute path to the file as a URL object (note the leading slash).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM