zoukankan      html  css  js  c++  java
  • 基于spring-boot的测试桩设计-添加配置文件(properties)

    编写测试时,有些内容可以放到配置文件中。

    第一步:新增配置文件 conf.properties

     

     第二步:编写配置文件类 MockConf

     1 package mock.mockdemo.conf;
     2 
     3 import lombok.Data;
     4 import org.springframework.beans.factory.annotation.Value;
     5 import org.springframework.context.annotation.PropertySource;
     6 import org.springframework.stereotype.Component;
     7 
     8 
     9 @Data
    10 @Component
    11 @PropertySource("classpath:config/conf.properties")
    12 public class MockConf {
    13     @Value("${user_num}")
    14     public String userNum;
    15 }

    第三步:添加接口和实现类

    接口:

    实现类:

     

     

     第四步:编写controller

    测试:

     

     结果:可以正常获取到配置文件内容

     源码地址:

    https://github.com/yuesest/mockdemo

  • 相关阅读:
    javascript对象继承的实现
    浏览器兼容问题汇总<转>
    DOM笔记
    Ajax日记
    学习态度
    项目1
    导航项目-整体布局
    有关布局
    导航项目开始
    windows 服务 定时程序 跑不出数据
  • 原文地址:https://www.cnblogs.com/moonpool/p/11521109.html
Copyright © 2011-2022 走看看