Skip to content

Commit a70682e

Browse files
committed
fix: Azure Funtion에서 Spring Bean 주입 오류 해결
1 parent 3b0d735 commit a70682e

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/main/java/org/inhahackers/optmo_user_be/function/UserFunction.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
import org.inhahackers.optmo_user_be.service.UserService;
1313
import org.springframework.context.ApplicationContext;
1414
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
15+
import org.springframework.stereotype.Component;
1516

1617
import java.util.Optional;
1718

19+
@Component
1820
@RequiredArgsConstructor
1921
public class UserFunction {
2022

21-
private static final ThreadLocal<ApplicationContext> contextHolder =
22-
ThreadLocal.withInitial(() ->
23-
new AnnotationConfigApplicationContext("org.inhahackers.optmo_user_be")
24-
);
23+
private final JwtTokenService jwtTokenService;
24+
private final UserService userService;
2525

2626
@FunctionName("userFunction")
2727
public HttpResponseMessage run(
@@ -36,11 +36,12 @@ public HttpResponseMessage run(
3636

3737
try {
3838
// 요청 바디 파싱
39-
ApplicationContext context = contextHolder.get();
40-
JwtTokenService jwtTokenService = context.getBean(JwtTokenService.class);
41-
UserService userService = context.getBean(UserService.class);
42-
4339
String email = request.getQueryParameters().get("email");
40+
if (email == null || email.isEmpty()) {
41+
return request.createResponseBuilder(HttpStatus.BAD_REQUEST)
42+
.body("Email parameter is required")
43+
.build();
44+
}
4445

4546
// 유저 정보 조회 및 생성
4647
var user = userService.findOrCreateUserByEmail(email);

0 commit comments

Comments
 (0)