config.properties ${user.dir}/src/main/resources/efps.cer 获取不到路径
时间: 2023-12-14 09:02:07 浏览: 31
可能是因为当前工作目录不是你所期望的目录,可以尝试使用绝对路径替代相对路径。比如,如果 `efps.cer` 文件在 `/home/user/certificates` 目录下,可以使用以下路径:
```
/home/user/certificates/efps.cer
```
如果你需要获取项目根目录的绝对路径,可以使用以下代码:
```java
String projectDir = System.getProperty("user.dir");
```
然后在路径中使用 `projectDir` 替代相对路径,比如:
```java
String certPath = projectDir + "/src/main/resources/efps.cer";
```
这样就可以获取到正确的路径了。
相关问题
java.io.FileNotFoundException: /storage/emulated/0/attestca.cer: open failed: ENOENT (No such file or directory)
这个错误提示是说找不到指定路径下的文件。可能是以下原因之一:
1. 文件路径错误:确认文件路径是否正确,文件是否存在;
2. 文件权限问题:确认应用程序是否有访问该文件的权限;
3. 程序逻辑问题:如果是在代码中动态生成文件路径,需要检查代码逻辑是否正确。
可以对代码进行调试,找出具体的原因,并进行相应的处理。
改为HTTPS,cert is in: /root/.acme.sh/www.niunai.store_ecc/www.niunai.store.cer cert key is in: /root/.acme.sh/www.niunai.store_ecc/www.niunai.store.key CA cert is in: /root/.acme.sh/www.niunai.store_ecc/ca.cer certs is there: /root/.acme.sh/www.niunai.store_ecc/fullchain.cer这是证书路径
好的,你可以按照以下步骤将证书配置到你的服务器上:
1. 将 `/root/.acme.sh/www.niunai.store_ecc/www.niunai.store.cer` 和 `/root/.acme.sh/www.niunai.store_ecc/www.niunai.store.key` 下载到你的服务器上,假设下载到了 `/etc/nginx/ssl` 目录下。
2. 在你的 Nginx 配置文件中增加以下内容:
```
server {
listen 443 ssl;
server_name yourdomain.com;
ssl_certificate /etc/nginx/ssl/www.niunai.store.cer;
ssl_certificate_key /etc/nginx/ssl/www.niunai.store.key;
# 其他 SSL 配置项
}
```
3. 重新加载 Nginx 配置文件,使之生效:
```
sudo service nginx reload
```
这样就可以使用 HTTPS 访问你的网站了。注意,为了保证 HTTPS 能够正常工作,你还需要确保你的服务器时间和证书的有效期是一致的。