programing

Spring Boot Framework에서는 @Spring Application Configuration, @Web Integration이 권장되지 않는 적절한 주석은 무엇입니까?

jooyons 2023. 3. 16. 21:21
반응형

Spring Boot Framework에서는 @Spring Application Configuration, @Web Integration이 권장되지 않는 적절한 주석은 무엇입니까?

이후 적절한 주석은 무엇입니까?@SpringApplicationConfiguration그리고.@WebIntegrationSpring Boot Framework 1.4에서는 권장되지 않습니다.난 유닛 테스트에 열중하고 있어.

권장되지 않는 클래스의 JavaDocs를 살펴봅니다.

* @deprecated as of 1.4 in favor of
 * {@link org.springframework.boot.test.context.SpringBootTest} with
 * {@code webEnvironment=RANDOM_PORT} or {@code webEnvironment=DEFINED_PORT}.
 */
...
@Deprecated
public @interface WebIntegrationTest {

* @deprecated as of 1.4 in favor of {@link SpringBootTest} or direct use of
* {@link SpringBootContextLoader}.
*/
...
@Deprecated
public @interface SpringApplicationConfiguration {

TestRestTemplate()를 대체할 수 있는 것도 있나요?

네, 여기 있습니다.

 * @deprecated as of 1.4 in favor of
 * {@link org.springframework.boot.test.web.client.TestRestTemplate}
 */
@Deprecated
public class TestRestTemplate extends RestTemplate {

지금 바로 시작하는 것이 좋습니다.Spring Boot 1.4의 개선 테스트.

기본적인 샘플은 다음과 같습니다.

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
public class MyTest {
}

다음 중 하나를 대체하기 위한 것입니다.

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(MyApp.class)
@WebIntegrationTest
public class MyTest {
}

@Enable을 사용할 수 있습니다.AutoConfiguration 또는 @SpringBootApplication.

테스트 목적으로 @SpringBootTest(webEnvironment='your value') 또는 간단히 @SpringBoot를 사용할 수 있습니다.시험

를 참조해 주세요.

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html

REST를 테스트하려면 @RestClientTest를 사용하여 RestTemplateBuilder를 구성할 수 있습니다.

다음 주석을 사용해야 합니다.

@ContextConfiguration(classes = main_class)

저는 지금까지 문제없이 아래를 사용하고 있습니다.

@ContextConfiguration(classes = Application.class)

반면 어플리케이션은 나의 메인 수업의 이름입니다.

언급URL : https://stackoverflow.com/questions/39417530/what-is-the-proper-annotation-since-springapplicationconfiguration-webintegra

반응형