@ContextConfiguration
and @SpringApplicationConfiguration
both are doing same. Both load and configure an ApplicationContext for integration tests. But @ContextConfiguration
has some lacking for support.@ContextConfiguration Supported Resource Types
Prior to
Spring 3.1
, only path-based resource locations (typically XML configuration files) were supported. As of Spring 3.1, context loaders may choose to support either path-based or class-based resources.
As of Spring 4.0.4, context loaders may choose to support path-based and class-based resources simultaneously. Consequently
@ContextConfiguration
can be used to declare either path-based resource locations (via the locations() or value() attribute) or annotated classes (via the classes() attribute).Note, however, that most implementations of SmartContextLoader only support a single resource type. As of Spring 4.1, path-based resource locations may be either XML configuration files or Groovy scripts (if Groovy is on the classpath). Of course, third-party frameworks may choose to support additional types of path-based resources.
@SpringApplicationConfiguration
is similar to the standard @ContextConfiguration
but uses Spring Boot's SpringApplicationContextLoader.
No comments:
Post a Comment