Skip to content

Commit 292df0b

Browse files
committed
fix: Azure Funtion에서 Spring Bean 주입 오류 해결
1 parent 1d231bf commit 292df0b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
import org.inhahackers.optmo_user_be.exception.JwtAuthenticationException;
1111
import org.inhahackers.optmo_user_be.service.JwtTokenService;
1212
import org.inhahackers.optmo_user_be.service.UserService;
13+
import org.springframework.context.ApplicationContext;
14+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
1315

1416
import java.util.Optional;
1517

1618
@RequiredArgsConstructor
1719
public class UserFunction {
1820

19-
private final JwtTokenService jwtTokenService;
20-
private final UserService userService;
21+
private static final ApplicationContext context =
22+
new AnnotationConfigApplicationContext("org.inhahackers.optmo_user_be");
2123

2224
@FunctionName("userFunction")
2325
public HttpResponseMessage run(
@@ -26,12 +28,15 @@ public HttpResponseMessage run(
2628
methods = {HttpMethod.POST},
2729
authLevel = AuthorizationLevel.ANONYMOUS)
2830
HttpRequestMessage<Void> request,
29-
final ExecutionContext context) {
31+
final ExecutionContext executionContext) {
3032

31-
context.getLogger().info("Processing userFunction request");
33+
executionContext.getLogger().info("Processing userFunction request");
3234

3335
try {
3436
// 요청 바디 파싱
37+
JwtTokenService jwtTokenService = context.getBean(JwtTokenService.class);
38+
UserService userService = context.getBean(UserService.class);
39+
3540
String email = request.getQueryParameters().get("email");
3641

3742
// 유저 정보 조회 및 생성
@@ -73,6 +78,7 @@ public HttpResponseMessage run(
7378
.build();
7479

7580
} catch (Exception e) {
81+
executionContext.getLogger().severe("ERROR: " + e.getMessage());
7682
return request.createResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR)
7783
.body("Internal error: " + e.getMessage())
7884
.build();

0 commit comments

Comments
 (0)