inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

@Bean 어노테이션 지정시 오류

465

dbskrltjq

작성한 질문수 1

0

안녕하세요 현재 [다국어 처리를 위한 Internationalization 구현] 강의를 수강하고 있습니다.

@SpringBootApplication 어노테이션이 있는 RestfulWebServiceApplication 클래스에서 localeResolver() 메소드에 @Bean 어노테이션을 지정하면 하단의 오류가 출력되는데 어디가 문제인지 도저히 모르겠습니다..


at kr.co.restfulwebservice.RestfulWebServiceTutorialApplication$$EnhancerBySpringCGLIB$$b793cc96.localeResolver(<generated>) ~[classes/:na]

at kr.co.restfulwebservice.RestfulWebServiceTutorialApplication.localeResolver(RestfulWebServiceTutorialApplication.java:22) ~[classes/:na]

at kr.co.restfulwebservice.RestfulWebServiceTutorialApplication$$EnhancerBySpringCGLIB$$b793cc96.CGLIB$localeResolver$0(<generated>) ~[classes/:na]

at kr.co.restfulwebservice.RestfulWebServiceTutorialApplication$$EnhancerBySpringCGLIB$$b793cc96$$FastClassBySpringCGLIB$$5b79685e.invoke(<generated>) ~[classes/:na]

at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.23.jar:5.3.23]

at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.23.jar:5.3.23]

spring-boot rest-api

답변 1

0

Dowon Lee

안녕하세요, 이도원입니다.

올려주신 메시지로는 정확한 원인을 찾기가 어렵지만, 만약 localeResolver 메소드가 사전에 Bean으로 이미 등록되어 있기 때문에, 애플리케이션을 실행할 수 없다는 에러 메시지도 발생한 경우라면, 아래와 같이, 기존에 등록 된 Bean을 재정의할 수 있도록 설정을 변경해 주신 다음에 실행해 보시기 바랍니다.

spring:
  messages:
    basename: messages
    fallback-to-system-locale: false

  main:
    #spring.main.allow-bean-definition-overriding=true
    allow-bean-definition-overriding: true

 

제가 테스트 한 코드는 Spring Boot 2.7.3 이며, 최신 코드는, 아래 githbu에서 확인해 보실 수 있습니다.

https://github.com/joneconsulting/my-restful-services

감사합니다.

JPA

0

60

1

jpa dependency를 추가하고 SecurityConfig클래스에서 오류가 납니다.

0

70

1

웹 브라우저 400 bad request

0

73

1

@Size는 되는데 @Past는 안 됩니다.

0

62

1

pdf 자료는 없나요?

0

75

2

locale 정보가 null 이면 무조건 messages_ko.properties이 호출 되는 문제

0

90

2

Swagger 강의, Unable to infer base url 이거 뜨시는 분들 도움되시라고

0

120

1

강의에서나온 화면 피피티

0

160

1

HelloWorldBean 관련 에러

0

186

2

Swagger API 3.x 오류..

0

222

1

java: variable message not initialized in the default constructor 에러는 어찌하면 좋을까요?

1

283

1

현재 GIT에 올리신 소스를 실행해봤습니다.

0

189

2

고양이 소리가 귀엽네요 !!

0

139

2

git에서 소스받고 실습중인데

0

119

1

post가 안되요

0

106

1

한국어 같은 경우 언어코드인 messages_ko.properties 로 생성하는게 더 좋지 않나요?

0

169

2

리턴타입으로서 EntityModel<User> 와 ResponseEntity질문

0

106

1

예외처리쪽 관련 질문있습니다.

0

160

2

엔티티가 바로 응답으로 나가도 되나요??

0

224

2

안녕하세여 Cannot invoke "co.kr.joneconsulting.resfulservice.repository.PostRepository.save(Object)" because "this.postRepository" is null

0

139

2

사용자 등록하고 나서 H2 에서 보면 신규 사용자의 password, ssn 이 null 로 되어 있습니다.

0

143

2

ApplictionContext 질문

0

195

2

롬북이 안먹히는것같아요

0

158

1

인텔리제이에서스프링부트 파일 실행하면

0

241

1