类 SpringBootContextLoader
- java.lang.Object
 - org.springframework.test.context.support.AbstractContextLoader
 - org.springframework.boot.test.context.SpringBootContextLoader
 
- 所有已实现的接口:
 org.springframework.test.context.ContextLoader,org.springframework.test.context.SmartContextLoader
public class SpringBootContextLoader extends org.springframework.test.context.support.AbstractContextLoader
AContextLoaderthat can be used to test Spring Boot applications (those that normally startup usingSpringApplication). Although this loader can be used directly, most test will instead want to use it withSpringBootTest.The loader supports both standard
MergedContextConfigurationas well asWebMergedContextConfiguration. IfWebMergedContextConfigurationis used the context will either use a mock servlet environment, or start the full embedded servlet container.If
@ActiveProfilesare provided in the test class they will be used to create the application context.- 另请参阅:
 SpringBootTest
构造器概要
构造器 构造器 说明 SpringBootContextLoader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Class<?>[]detectDefaultConfigurationClasses(Class<?> declaringClass)Detect the default configuration classes for the supplied test class.protected String[]getInlinedProperties(org.springframework.test.context.MergedContextConfiguration config)protected StringgetResourceSuffix()protected String[]getResourceSuffixes()protected org.springframework.boot.SpringApplicationgetSpringApplication()Builds newSpringApplicationinstance.org.springframework.context.ApplicationContextloadContext(String... locations)org.springframework.context.ApplicationContextloadContext(org.springframework.test.context.MergedContextConfiguration config)voidprocessContextConfiguration(org.springframework.test.context.ContextConfigurationAttributes configAttributes)
构造器详细资料
SpringBootContextLoader
public SpringBootContextLoader()
方法详细资料
loadContext
public org.springframework.context.ApplicationContext loadContext(org.springframework.test.context.MergedContextConfiguration config) throws Exception
- 抛出:
 Exception
getSpringApplication
protected org.springframework.boot.SpringApplication getSpringApplication()
Builds newSpringApplicationinstance. You can override this method to add custom behavior- 返回:
 SpringApplicationinstance
getInlinedProperties
protected String[] getInlinedProperties(org.springframework.test.context.MergedContextConfiguration config)
processContextConfiguration
public void processContextConfiguration(org.springframework.test.context.ContextConfigurationAttributes configAttributes)
- 指定者:
 processContextConfiguration在接口中org.springframework.test.context.SmartContextLoader- 覆盖:
 processContextConfiguration在类中org.springframework.test.context.support.AbstractContextLoader
detectDefaultConfigurationClasses
protected Class<?>[] detectDefaultConfigurationClasses(Class<?> declaringClass)
Detect the default configuration classes for the supplied test class. By default simply delegates toAnnotationConfigContextLoaderUtils.detectDefaultConfigurationClasses(java.lang.Class<?>).- 参数:
 declaringClass- the test class that declared@ContextConfiguration- 返回:
 - an array of default configuration classes, potentially empty but never 
null - 另请参阅:
 AnnotationConfigContextLoaderUtils
loadContext
public org.springframework.context.ApplicationContext loadContext(String... locations) throws Exception
- 抛出:
 Exception
getResourceSuffixes
protected String[] getResourceSuffixes()
- 覆盖:
 getResourceSuffixes在类中org.springframework.test.context.support.AbstractContextLoader
getResourceSuffix
protected String getResourceSuffix()
- 指定者:
 getResourceSuffix在类中org.springframework.test.context.support.AbstractContextLoader