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

  • 相关阅读:
    python -django 之第三方支付
    python 的排名,已经python的简单介绍
    第三方登录
    linux 基础命令
    JWT 加密
    Docker 简介
    中文分词库:结巴分词
    Django websocket 长连接使用
    jQuery截取字符串的几种方式
    Python 操作redis
  • 原文地址:https://www.cnblogs.com/lixuwu/p/6697537.html
Copyright © 2011-2022 走看看