zoukankan      html  css  js  c++  java
  • (转)@ContextConfiguration注解说明

    场景:学习spring实战中相关的单元测试

    1 正常使用

    @ContextConfiguration Spring整合JUnit4测试时,使用注解引入多个配置文件

    1.1 单个文件

    @ContextConfiguration(locations="../applicationContext.xml")

    @ContextConfiguration(classes = SimpleConfiguration.class)

    1.2 多个文件

    可用{}

    @ContextConfiguration(locations = { "classpath*:/spring1.xml", "classpath*:/spring2.xml" })

    1.3 默认不写

    可以根据测试的类名,去找到与之对应的配置文件。

     异常情况:

    异常信息

    四月 12, 2017 9:38:10 上午 org.springframework.test.context.support.AbstractContextLoader generateDefaultLocations
    信息: Could not detect default resource locations for test class [soundsystem.CNamespaceValueTest]: class path resource [soundsystem/CNamespaceValueTest-context.xml] does not exist
    四月 12, 2017 9:38:10 上午 org.springframework.test.context.support.AnnotationConfigContextLoaderUtils detectDefaultConfigurationClasses
    信息: Could not detect default configuration classes for test class [soundsystem.CNamespaceValueTest]: CNamespaceValueTest does not declare any static, non-private, non-final, inner classes annotated with @Configuration.

    1

  • 相关阅读:
    tcp socket http(复制的)
    cas php
    占用字节
    网络基础
    Mbps MB/S Mb/s
    path_info和get_full_path()的区别
    rbac权限管理
    ORM _meta
    Django SQLite3的使用
    url的分发
  • 原文地址:https://www.cnblogs.com/lixuwu/p/6697537.html
Copyright © 2011-2022 走看看