zoukankan      html  css  js  c++  java
  • spring profile机制测试

    新建spring普通maven项目:
    ------------------------
    方式一使用ClassPathXmlApplicationContext
    打开idea-->new-->project-->选择maven-->选择maven模板quickstart-->添加spring依赖spring-core、spring-context、spring-beans、spring-test及junit-->创建bean-->创建spring xml配置文件,配置profile-->在main方法创建ClassPathXmlApplicationContext并传入参数为配置文件地址
    ------------------------
    方式二使用AnnotationConfigApplicationContext
    打开idea-->new-->project-->选择maven-->选择maven模板quickstart-->添加spring依赖spring-core、spring-context、spring-beans、spring-test及junit-->创建bean-->创建java配置类,放在最外层包,方法上添加Profile注解-->在main方法创建AnnotationConfigApplicationContext并传入最外层包
    ------------------------
    设置系统环境变量:
    spring.profiles.default dev
    ------------------------
    运行test包里的方法

    ------------------------

    代码示例:https://github.com/ChangMike/spring-profile-test

  • 相关阅读:
    PDO的预处理操作
    关于OOP(面向对象)
    关于MySql
    任务三
    任务二
    php文件操作
    php的会话技术
    php的常量 、变量和作用域
    php的函数和超全局变量
    预发布环境和分支部署
  • 原文地址:https://www.cnblogs.com/Mike_Chang/p/12723772.html
Copyright © 2011-2022 走看看