cxf-rs 、spring 和 swagger 环境配置切换【github 有项目】
环境切换的目的是 准生产和生产环境切换时,只修改一个文件就可以达到效果
在spring bean 文件中 配置:
<bean class="cn.zno.common.context.GServletContext"></bean>
package cn.zno.common.context;
import java.util.Date;
import javax.servlet.ServletContext;
import org.springframework.web.context.ServletContextAware;
public class GServletContext implements ServletContextAware {
private ServletContext servletContext;
@Override
public void setServletContext(ServletContext servletContext) {
this.servletContext=servletContext;
getServletContext().setAttribute("resouceVersion", new Date().getTime());
getServletContext().setAttribute("swaggerPath", "http://localhost:8080/cxf-rs-swagger");
}
public ServletContext getServletContext() {
return servletContext;
}
}
在index.jsp 中使用
url = "${swaggerPath}/api/swagger.json";
再进一步:
把"http://localhost:8080/cxf-rs" 值配置到 properties 文件中
swagger.path=http://localhost:8080/cxf-rs-swagger
spring bean 中
<util:properties id="config" location="classpath:conf/config.properties"></util:properties>
常量文件
package cn.zno.common.constants; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; @Component
public class ApplicationConstants { public static String SWAGGER_PATH; @Autowired(required = true)
public void setSWAGGER_PATH(@Value("#{config['swagger.path']}") String SWAGGER_PATH) {
ApplicationConstants.SWAGGER_PATH = SWAGGER_PATH;
}
}
使用该常量
getServletContext().setAttribute("swaggerPath", ApplicationConstants.SWAGGER_PATH);
完整项目:
git@github.com:witaste/cxf-rs-swagger.git
cxf-rs 、spring 和 swagger 环境配置切换【github 有项目】的更多相关文章
- 一分钟学会Spring Boot多环境配置切换
一. 问题由来 开发环境.测试环境.生产环境--------我们的软件在不同的环境中,系统参数和配置可能会不一样,比如数据源配置.日志文件配置.以及一些软件运行过程中的基本配置,那每次我们将软件部署到 ...
- SpringCloud入门之Spring Boot多环境配置切换指南
在 spring boot 中,有两种配置文件,一种是application.properties,另一种是application.yml,两种都可以配置spring boot 项目中的一些变量的定义 ...
- springboot笔记05——profile多环境配置切换
前言 一个应用程序从开发到上线,往往需要经历几个阶段,例如开发.测试.上线.每个阶段所用到的环境的配置可能都是不一样的,Springboot 应用可以很方便地在各个环境中对配置进行切换.所以,今天主要 ...
- idea spring+springmvc+mybatis环境配置整合详解
idea spring+springmvc+mybatis环境配置整合详解 1.配置整合前所需准备的环境: 1.1:jdk1.8 1.2:idea2017.1.5 1.3:Maven 3.5.2 2. ...
- Spring多开发环境配置
在项目开发中,多环境的的配置可以方便在不同环境的切换,减少错误的产生 一.properties文件的多环境配置 properties文件可以根据不同的后缀来区分不同的环境 application.pr ...
- Spring Boot多环境配置
在项目开发阶段,开发环境和实际生产环境是不一样,比如使用的数据库/服务连接配置等.因此,配置多个开发环境profile还是必要的 多环境的配置(yml)方式 配置其实很简单,在resource目录下, ...
- swagger-ui 系统配置过程(基于spring+springmvc+swagger+springfox配置 web-api 管理系统)
web工程部分框架信息:spring springmvc swagger springfox maven 参考文档:https://www.cnblogs.com/exmyth/p/7183753.h ...
- 嗯,挺全乎儿的,Spring Boot 多环境配置都在这里了,你喜欢哪种?
持续原创输出,点击上方蓝字关注我 目录 前言 Spring Boot 自带的多环境配置 创建不同环境的配置文件 指定运行的环境 Maven 的多环境配置 创建多环境配置文件 定义激活的变量 pom 文 ...
- Java开发学习(三十二)----Maven多环境配置切换与跳过测试的三种方式
一.多环境开发 我们平常都是在自己的开发环境进行开发, 当开发完成后,需要把开发的功能部署到测试环境供测试人员进行测试使用, 等测试人员测试通过后,我们会将项目部署到生成环境上线使用. 这个时候就有一 ...
随机推荐
- you boot volume has only 0 byte size
懒人方法: uname -a 列出目前使用的内核 dpkg -l | grep linux-image 列出存在的linux内核 sudo apt-get purge linux-image-3.16 ...
- webserive学习记录2-cxf框架基础使用
cxf是一个webservice的框架,类似的还有axis,下面说一下cxf的基本使用. 首先要下载cxf的文件,然后要在项目中引入jar包,当然也可以通过maven进行管理.我用的是最新的3.2.1 ...
- 【转】Phong和Blinn-Phong光照模型
来自:http://www.cnblogs.com/bluebean/p/5299358.html Phong和Blinn-Phong是计算镜面反射光的两种光照模型,两者仅仅有很小的不同之处. 1.P ...
- nginx的配置文件解析
worker_processes ;#工作进程的个数,一般与计算机的cpu核数一致 events { worker_connections ;#单个进程最大连接数(最大连接数=连接数*进程数) } h ...
- ArcGIS案例学习笔记4_1
ArcGIS案例学习笔记4_1 联系方式:谢老师,135-4855-4328, xiexiaokui(#)qq.com 时间:第四天上午 案例1:矢量校正案例 教程:Editing编辑教程 pdf 数 ...
- URLconf
URLconf 浏览者通过在浏览器的地址栏中输入网址请求网站,对于Django开发的网站,由哪一个视图进行处理请求,是由url匹配找到的 配置 在test3/settings.py中通过ROOT_UR ...
- dhtmlx uploader使用
前端:{type : "upload", mode : "html4", name : "importFile", inputWidth : ...
- SQLserver和oracle中对应的数据类型
- 利用redis完成自动补全搜索功能(二)
前面介绍了自动完成的大致思路,现在把搜索次数的功能也结合上去.我采用的是hash表来做的,当然也可以在生成分词的时候,另外一个有序集合来维护排序, 然后2个有序集合取交集即可.这里介绍hash的方式来 ...
- C#中获取串口与并口列表
//获取系统中的串口并加入到下拉框中 cbCashBoxPort.Items.Clear(); string[] ports = System.IO.Ports.SerialPort.GetPortN ...