• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

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

22.05.27 00:55 작성 조회수 3.53k

1

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

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

답변 2

·

답변을 작성해보세요.

0

yunbinni님의 프로필

yunbinni

2022.06.03

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

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

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

 

그래서 콘솔을 보니까

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

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

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

edowon0623@gmail.com

감사합니다.

backend님의 프로필

backend

질문자

2022.05.30

감사합니다.

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

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

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));
}

// 생략

 

감사합니다.