SpringApplicationConfiguration not found: Erroneous spring-boot-starter-test content?

前端 未结 3 1849
[愿得一人]
[愿得一人] 2020-12-24 03:05

Getting a compilation error in Maven:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] --------------         


        
3条回答
  •  滥情空心
    2020-12-24 03:43

    As the error is due to the upgrade of Spring Boot from 1.4 to 1.5, its important to note (from below) that several new classes that are introduced in 1.4 deprecated some of the existing classes leading way to finally getting removed in 1.5. The details of such can be found at: Spring boot release notes

    Quoted from website (edited):

    Additionally, Spring Boot 1.4 (and above) attempts to rationalize and simplify the various ways that a Spring Boot test can be run. You should migrate the following to use the new @SpringBootTest annotation:

    From @SpringApplicationConfiguration(classes=MyConfig.class) to @SpringBootTest(classes=MyConfig.class)

    From @ContextConfiguration(classes=MyConfig.class, loader=SpringApplicationContextLoader.class) to @SpringBootTest(classes=MyConfig.class)

    From @IntegrationTest to @SpringBootTest(webEnvironment=WebEnvironment.NONE)

    From @IntegrationTest with @WebAppConfiguration to @SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT) (or RANDOM_PORT)

    From @WebIntegrationTest to @SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT) (or RANDOM_PORT)

    Tip Whilst migrating tests you may also want to replace any @RunWith(SpringJUnit4ClassRunner.class) declarations with Spring 4.3’s more readable @RunWith(SpringRunner.class).

提交回复
热议问题