藉助一下軟體版廣大的人氣,請問板上前輩們
小弟有Maven專案資料夾結構如下:
Project
├src/main/java
│ └ com.abc.xyz
│ └Auth.java
└src/main/resources
└certs
└credential.p12
Auth.java裡有段程式碼用來驗證:
=====================================================================
File file = new File(classLoader.getResource("cert.p12").getFile());
String filePath = file.getAbsolutePath();
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
.setServiceAccountScopes(Collections.singleton(
CalendarScopes.CALENDAR_READONLY))
.setServiceAccountPrivateKeyFromP12File(new File(filePath))
.setServiceAccountUser(SERVICE_ACCOUNT_USER)
.build();
=====================================================================
將該專案檔的jar部署到Server上後
會出現找不到credential檔案的錯誤訊息
想請問credential檔案應該放在專案或server哪裡才能被找到?
又該怎麼指定路徑呢?