programing

"새로운 사일런트 종료" 중단점이클립스 + 스프링 부트의 예외()"

bestcode 2022. 9. 24. 12:42
반응형

"새로운 사일런트 종료" 중단점이클립스 + 스프링 부트의 예외()"

Eclipse IDE(Spring Tool Suite)의 디버깅모드로 Spring Boot 프로젝트를 실행할 때마다 스레드가 정지합니다.throw new SilentExitException();중단점이 없어도 선을 그을 수고를 덜 수 있습니다.

이 동작을 회피할 수 있는 방법이 있습니까?

org.springframework.boot.devtools.restart.SilentExitExceptionHandler.exitCurrentThread() (line 53):

public static void exitCurrentThread() {
    throw new SilentExitException();
}

이 문제는 1.3.0 마일스톤으로 업그레이드한 후에 시작됩니다.

스프링 툴 스위트

Version: 3.7.0.RELEASE
Build Id: 201506290649

플랫폼:

Eclipse Luna SR2 (4.4.2)

이것은 유감스럽게도 새로운 것에 관한 알려진 문제입니다.spring-boot-devtools모듈(https://github.com/spring-projects/spring-boot/issues/3100) 참조).이 방법을 사용하여 메인 스레드를 제거하여 다시 로드할 수 있는 버전으로 교체합니다.디버깅 브레이크포인트가 트리거되지 않도록 하는 방법은 아직 발견되지 않았습니다.

현재 Java -> [ Debug ]프리퍼런스에서 [Suspend exceptions on uncapted exceptions]체크박스를 켜지 않도록 할 수 있습니다.

속성을 VM 인수로 추가합니다.

-Dspring.devtools.restart.enabled=false

여기에 이미지 설명 입력

이렇게 하면 다음과 같이 코드를 변경할 필요가 없습니다.

System.setProperty("spring.devtools.restart.enabled", "false");

Eclipse on Debug 모드에서는 이미 제한된 핫패치를 사용할 수 있기 때문에 대부분의 경우 새로고침이 역효과를 내기 때문에 다음과 같이 비활성화하기로 결정했습니다.

System.setProperty("spring.devtools.restart.enabled", "false");

참고 자료: https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#using-boot-devtools-restart-disable

이 예외는 새로고침에 의해 발생하므로 이 문제도 해결됩니다.다음 명령어를 사용해야 합니다.System.setProperty설정하지 않고 메서드application.properties.

회피책:

public static void main(String[] args) {
    try {
        SpringApplication.run(App.class, args);
    } catch (Throwable e) {
        if(e.getClass().getName().contains("SilentExitException")) {
            LOGGER.debug("Spring is restarting the main thread - See spring-boot-devtools");
        } else {
            LOGGER.error("Application crashed!", e);
        }
    }
}

우리가 무시해도 상관없다.SilentExitException왜냐하면 devtools는 v-instance를 사용하여 인스턴스를 재시작하고 있기 때문입니다.SilentExitException그렇게 조용하진 않아요이 시도 블록이 조용하게...

수업시간에 텍스트 매칭을 사용해서SilentExitException은 비공개입니다.SilentExitExceptionHandler.

그게 네 문제를 해결해주진 않아...

다음 항목을 알 수 없는 예외로 삭제하면 거기서 끊어지지 않습니다.

불행히도, 나는 이것이 영구적일 방법을 찾지 못했지만, 다음 번 일식을 재개할 때까지 지속될 것이다.

범위 런타임에 devtools 실행:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
</dependency>

스프링 부트 프로젝트를 진행하면서 같은 문제가 발생하였습니다.Main method에 사용되는 TRY CATCH 블록을 찾았습니다.

코드 실행 시도 캐치 블록을 제거합니다.그 오류는 재발하지 않을 것이다.다음과 같습니다.

public static void main(String[] args) {

    SpringApplication.run(TrewAuthApplication.class, args);

}

application.properties 파일에서 이를 true로 설정합니다.

spring.devtools.restart.enabled=false

또한 spring 클라우드 구성 서버를 사용하는 경우 이 기능을 사용할 수 있는 속성 타이 파일이 없는지 확인하십시오.

Kotlin에서의 회피책:

@JvmStatic
fun main(args: Array<String>) {
  val app = SpringApplication(Application::class.java)
  try {
    app.run(*args)
  } catch (e: Exception) {
    preventNonNullExitCodeOnSilentExitException(e)
  }
}

private fun preventNonNullExitCodeOnSilentExitException(e: Exception) {
  if (e.toString().contains("SilentExitException")) {
    log.info("Ignoring Silent Exit Exception...")
    e.printStackTrace()
    return
  }
  throw e
}

언급URL : https://stackoverflow.com/questions/32770884/breakpoint-at-throw-new-silentexitexception-in-eclipse-spring-boot

반응형