Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
[#55] 외부에서 주입한 설정 값을 사용할 수 있도록 수정
Browse files Browse the repository at this point in the history
- PathResource()를 FileSystemResource()로 수정
  • Loading branch information
cyj199637 committed Jan 11, 2021
1 parent 52d5e4a commit c0ecd60
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/java/me/liiot/snsserver/config/FirebaseConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.PathResource;

import javax.annotation.PostConstruct;
Expand All @@ -30,7 +31,7 @@ public class FirebaseConfig {
@PostConstruct
public void initialize() {
try {
InputStream serviceAccount = new PathResource(apiKeyPath).getInputStream();
InputStream serviceAccount = new FileSystemResource(apiKeyPath).getInputStream();

FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.extern.slf4j.Slf4j;
import me.liiot.snsserver.enumeration.PushType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.PathResource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void sendPushMessage(String userId, String receiverId, PushType type, Str
private String getAccessToken() {
try {
GoogleCredential googleCredential = GoogleCredential
.fromStream(new PathResource(apiKeyPath).getInputStream())
.fromStream(new FileSystemResource(apiKeyPath).getInputStream())
.createScoped(Arrays.asList("https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/firebase.messaging"));
googleCredential.refreshToken();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ spring.redis.cache.host=localhost
spring.redis.cache.port=6380

#Firebase Service
firebase.account.key.path=src/main/resources/sns-itda-firebase-adminsdk.json
firebase.account.key.path=C:\\Users\\cyj19\\Desktop\\Project\\sns-server\\src\\main\\resources\\sns-itda-firebase-adminsdk.json

0 comments on commit c0ecd60

Please sign in to comment.