> For the complete documentation index, see [llms.txt](https://wannaqueen.gitbook.io/spring5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wannaqueen.gitbook.io/spring5/spring-boot/undefined-1/23.-spring-application-by-ys/23.6.md).

# 23.6 웹 환경

`SpringApplication`은 어플리케이션에 맞는 타입의 `ApplicationContext`를 생성하기 위해 시도한다. 기본적으로, **웹어플리케이션인지 아닌지를 기반으로 `AnnotationConfigApplicationContext`나 `AnnotationConfigServletWebServerApplicationContext`가 사용된다**

`웹 환경`인지를 결정하기 위해 사용하는 알고리즘은 꽤 단순하다. (이것은 몇몇 클래스들이 존재하는지에 기초한다.) 만약 기본설정을 재정의하려고 하면 `setWebEnvironment(boolean webEnvironment)` 메소드를 사용한다.

`setApplicationContextClass(...)`를 사용해서 사용할 `ApplicationContext` 타입을 직접 지정할 수도 있다.

| ![\[팁\]](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/images/tip.png) |
| --------------------------------------------------------------------------------------------- |
| **JUnit test에서 `SpringApplication`을 사용할 때 종종 `setWebEnvironment(false)`를 사용한다.**              |

### <br>
