Skip to content

Commit 8902472

Browse files
authored
Merge pull request #1 from JeroCaller/chore/change-configure
chore: 프로젝트 설정 변경 및 외부에서의 환경 설정 변경 가능하도록 리팩토링
2 parents e2c99b5 + 22e218b commit 8902472

File tree

8 files changed

+75
-66
lines changed

8 files changed

+75
-66
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ out/
4343
.metadata/
4444

4545
settings.gradle
46-
46+
application-*.yml

src/main/java/com/acorn/AcornPrivateApplication.java renamed to src/main/java/com/acorn/ForklogBackendApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
@SpringBootApplication
2121
@EnableFeignClients(basePackages = "com.acorn.api.openfeign")
2222
@EnableSpringDataWebSupport(pageSerializationMode = PageSerializationMode.VIA_DTO)
23-
public class AcornPrivateApplication {
23+
public class ForklogBackendApplication {
2424

2525
public static void main(String[] args) {
26-
SpringApplication.run(AcornPrivateApplication.class, args);
26+
SpringApplication.run(ForklogBackendApplication.class, args);
2727
}
2828

2929
}

src/main/java/com/acorn/api/openfeign/KakaoOpenFeignConfig.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public class KakaoOpenFeignConfig {
1414
@Value("${kakao.rest_api_key}")
1515
private String kakaoApiKey;
1616

17+
@Value("${feign.logger.level}")
18+
private Level feignLoggerLevel;
19+
1720
@Bean
1821
public RequestInterceptor kakaoRequestInterceptor() {
1922
return requestTemplate -> {
@@ -23,13 +26,14 @@ public RequestInterceptor kakaoRequestInterceptor() {
2326

2427
/**
2528
* Feign Logging을 위한 설정.
29+
* feign.logger.level 환경 변수 값을 이용함.
2630
*
2731
* REST API 키가 이클립스 콘솔창에 노출되니 정말 필요할 때만 사용!
2832
* @author JeroCaller (JJH)
2933
*/
3034
@Bean
3135
public Logger.Level feignLoggerLevel() {
32-
return Level.FULL;
36+
return feignLoggerLevel;
3337
}
3438

3539
}

src/main/java/com/acorn/config/SecurityConfig.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.nio.file.Paths;
66
import java.util.List;
77

8+
import org.springframework.beans.factory.annotation.Value;
89
import org.springframework.context.annotation.Bean;
910
import org.springframework.context.annotation.Configuration;
1011
import org.springframework.security.authentication.AuthenticationManager;
@@ -37,6 +38,9 @@
3738
@RequiredArgsConstructor
3839
public class SecurityConfig implements WebMvcConfigurer {
3940

41+
@Value("${file.upload-dir}")
42+
private String uploadBaseDir;
43+
4044
@Bean
4145
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity, JwtAuthenticationFilter jwtAuthenticationFilter) throws Exception {
4246
// CORS 설정과 CSRF 비활성화, 세션 관리 정책 설정
@@ -84,7 +88,8 @@ public PasswordEncoder PasswordEncoder() {
8488
public void addResourceHandlers(ResourceHandlerRegistry registry) {
8589
//정적리소스(이미지,css,js,데이터 경로) 추가 설정
8690
//지금은 업로드 경로 설정이 목적
87-
Path uploadDir = Paths.get("./uploads");
91+
//Path uploadDir = Paths.get("./uploads");
92+
Path uploadDir = Paths.get(uploadBaseDir);
8893
//uploads 절대 경로 얻기
8994
String uploadPath = uploadDir.toFile().getAbsolutePath();
9095
// /uploads/test.png라는 url이 들어오면 uploads디렉토리 내의 test.png를 반환

src/main/resources/application.properties

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/main/resources/application.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
spring:
2+
application:
3+
name: forklog_backend
4+
5+
profiles:
6+
include: secret
7+
# dev, prod
8+
active: dev
9+
10+
jpa:
11+
# 지연로딩 설정
12+
open-in-view: false
13+
properties:
14+
hibernate:
15+
show_sql: true
16+
format_sql: false
17+
use_sql_comments: true
18+
dialect: org.hibernate.dialect.MariaDBDialect
19+
20+
# feign configuration
21+
cloud:
22+
openfeign:
23+
httpclient:
24+
connection-timeout: 5000
25+
ok-http:
26+
read-timeout: 5000
27+
28+
# file upload configuration
29+
servlet:
30+
multipart:
31+
enabled: true
32+
max-file-size: 10MB
33+
max-request-size: 10MB
34+
35+
web:
36+
resources:
37+
# react project path mapping
38+
add-mappings: true
39+
40+
server:
41+
port: 8080
42+
43+
# security logging
44+
logging:
45+
level:
46+
org:
47+
springframework:
48+
security: DEBUG
49+
web:
50+
cors: DEBUG
51+
52+
# feign log
53+
com:
54+
acorn:
55+
api:
56+
openfeign:
57+
KakaoRestOpenFeign: DEBUG
58+
59+
# upload directory
60+
file:
61+
upload-dir: ./uploads

uploads/184_우주강아지.png

972 KB
Loading

uploads/185_우주강아지.png

972 KB
Loading

0 commit comments

Comments
 (0)