inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

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

Level3 단계의 REST API 구현을 위한 HATEOAS 적용

프로젝트 실행 시 Process finished with exit code 0 출력 후 서버 가동이 안됩니다

4261

backend

작성한 질문수 1

1

이전에는 정상적으로 서버가 작동했는데 갑자기 프로젝트 Run 시 Process finished with exit code 0과 함께 서버가 동작하지 않습니다.

debug를 해보니 Disconnected from the target VM, address: '127.0.0.1:00000', transport: 'socket' 이라고 뜨는데 구글링 해봐도 원인을 잘 모르겠습니다. (address 값은 질문글 작성을 위해 바꿨습니다) 

spring-boot rest-api

답변 2

0

포근포근한 수달

질문자님과 강사님 모두 감사드립니다.

저도 같은 오류가 났기에 강사님 답변처럼 조치를 취해봤는데

제 경우엔 오류가 또 나더라구요.

 

그래서 콘솔을 보니까

Description:

The bean 'localeResolver', defined in com.example.restfulwebservice.RestfulWebServiceApplication, could not be registered. A bean with that name has already been defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true


Process finished with exit code 0

이런 메시지를 냈습니다.

이전에 main함수 밑에 만들었던 LocalResolver 빈을 오버라이딩 하지 못하도록 되어있다고 적혀있었습니다.

@EnableWebMvc에 포함된 @Import({DeleationWebMvcConfiguration})에서

이미 정의가 되어있던 것이었습니다.(정확히는 상속해준 부모 클래스에서요.)

 

그래서 오류메시지에서 Action을 하라는 것이 yml파일에서 설정하는 것 같아서

아래와 같이 yml 파일에,,,

spring:
#...(생략)..
main:
allow-bean-definition-overriding: true

이렇게 오버라이딩을 가능하도록 true로 설정하고 다시 했는데 이번엔 되었습니다!

참고하실 수 있도록 글 올립니다.

0

Dowon Lee

정보 공유 감사합니다.

0

Dowon Lee

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

올려주신 에러 메시지만으로는 원인을 파악하기 쉽지 않네요. 아래 메일로 전체 로그를 보내주시면 원인을 찾는데 도움이 될 것 같습니다. 

edowon0623@gmail.com

감사합니다.

0

backend

감사합니다.

해당 메일로 디버그 완료한 전체 로그 보내드렸습니다!

0

Dowon Lee

메일 확인하고 답변 드립니다. 

spring boot 2.6.x 하고 swagger-ui의 라이브러리 충돌 문제가 아직 해결되지 않은 것 같습니다. 아래와 같이 설정해서 실행해 보시기 바랍니다. 

1. Application 클래스에 @EnableWebMvc 추가

@SpringBootApplication
@EnableWebMvc
public class MyRestfulServicesApplication {

public static void main(String[] args) {
SpringApplication.run(MyRestfulServicesApplication.class, args);
}

 

2. SwaggerConfig 클래스에 아래 메소드 추가 (webEndpointServletHandlerMapping)

@Configuration
@EnableSwagger2
public class SwaggerConfig {

// ... 생략

// 아래 메소드 추가
@Bean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier,
ServletEndpointsSupplier servletEndpointsSupplier,
ControllerEndpointsSupplier controllerEndpointsSupplier,
EndpointMediaTypes endpointMediaTypes,
CorsEndpointProperties corsProperties,
WebEndpointProperties webEndpointProperties,
Environment environment) {
List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
allEndpoints.addAll(webEndpoints);
allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
String basePath = webEndpointProperties.getBasePath();
EndpointMapping endpointMapping = new EndpointMapping(basePath);
boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(),
new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
}

private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
}

// 생략

 

감사합니다. 

JPA

0

71

1

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

0

84

1

웹 브라우저 400 bad request

0

87

1

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

0

77

1

pdf 자료는 없나요?

0

95

2

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

0

103

2

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

0

137

1

강의에서나온 화면 피피티

0

169

1

HelloWorldBean 관련 에러

0

194

2

Swagger API 3.x 오류..

0

231

1

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

1

295

1

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

0

203

2

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

0

150

2

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

0

129

1

post가 안되요

0

119

1

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

0

177

2

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

0

113

1

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

0

166

2

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

0

240

2

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

0

152

2

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

0

146

2

ApplictionContext 질문

0

199

2

롬북이 안먹히는것같아요

0

162

1

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

0

244

1