公司使用dubbo开发,提供了很多的服务,每个服务中一些配置都是一样的,比如注册中心地址,公共码表库等一下配置,这样在部署每一个程序的时候,修改每一个服务的配置增加很多的工作量。且领导不想对程序有大的改动(不然可以引用配置中心解决)。在此情况下使用spring加载放在服务外的配置的方式来解决这个问题。

1、代码中指定

测试代码中:

String path = AppTest.class.getClassLoader().getResource("").toString();
System.out.println(path);
System.setProperty("config", path+"config.properties");

spring配置方式

<context:property-placeholder ignore-unresolvable="true" location="classpath:dubbo.properties,${config}" />

在正式环境中部署

Java的System.setProperty("config", path+"config.properties");这个设置,可以通过jvm的参数来传递

-Dconfig=file:/E:/yunyanWork/ceye/analysis_service/target/test-classes/config.properties

spring 通过启动命令配置文件路径的更多相关文章

  1. Spring Boot启动命令参数详解及源码分析

    使用过Spring Boot,我们都知道通过java -jar可以快速启动Spring Boot项目.同时,也可以通过在执行jar -jar时传递参数来进行配置.本文带大家系统的了解一下Spring ...

  2. Spring和junit测试之配置文件路径

    本人在测试一个方法时需要加载XML配置文件,spring提供了相应的方法,就小小研究了下,在此记录下具体的过程,方便初学者和自己日后回顾. Spring容器最基本的接口就是BeanFactory. B ...

  3. Linux crontab 命令详解(含配置文件路径)

    编辑/etc/crontab 文件配置cron cron 服务每分钟不仅要读一次/var/spool/cron内的所有文件,还需要读一次/etc/crontab,因此我们配置这个文件也能运用cron服 ...

  4. 【docker】docker部署spring boot服务 选择配置文件启动

    默认启动命令: docker run --name swapping -itd --net=host -v /etc/localtime:/etc/localtime:ro -v /etc/timez ...

  5. Atitit. 软件GUI按钮与仪表盘--web服务器区--获取apache配置文件路径 linux and apache的启动、停止、重启

    Atitit.   软件GUI按钮与仪表盘--web服务器区--获取apache配置文件路径 linux and apache的启动.停止.重启 可以通过"netstat -anp" ...

  6. Atitit. 软件GUIbutton与仪表盘--webserver区--获取apache配置文件路径 linux and apache的启动、停止、重新启动

    Atitit.   软件GUIbutton与仪表盘--webserver区--获取apache配置文件路径 linux and apache的启动.停止.重新启动 能够通过"netstat  ...

  7. 微服务架构 | *2.3 Spring Cloud 启动及加载配置文件源码分析(以 Nacos 为例)

    目录 前言 1. Spring Cloud 什么时候加载配置文件 2. 准备 Environment 配置环境 2.1 配置 Environment 环境 SpringApplication.prep ...

  8. 【Azure 应用服务】部署Jar到App Service for Linux,因启动命令路径配置错误而引起:( Application Error 问题

    问题描述 App Service for Linux 资源创建完成后,通过FTP方式把 .jar包(logdemo.jar)包上传到 /site/wwwroot/ 文件夹后,在App Service的 ...

  9. bat中实现代码拷贝到指定目录后启动命令行并更改默认路径

      ### window书写shell脚本,实现判断指定文件是否存在,存在就删除,然后复制新文件到此目录 ``` if exist "G:\test\test2\1.txt" (d ...

随机推荐

  1. Mac下Pycharm中升级pip失败,通过终端升级pip

    使用 Pycharm 使,需要下载相关的第三方包,结果提示安装失败,提示要升级 pip 版本,但是通过 Pycharm 重新安装却失败,原因可能是出在通过 Pycharm 时升级 pip 是没有权限的 ...

  2. 【2019.11.27】SDN上机第5次作业

    参考资料: https://www.cnblogs.com/zzqsss/p/11924685.html 问答环节 描述官方教程实现了一个什么样的交换机功能? Ryu是一个基于组件的软件定义的网络框架 ...

  3. Java自己实现HTTP服务器来理解GET和POST区别

    GET请求和POST请求有什么区别?GET请求的参数在URL的问号后面显示,而POST参数不在URL上:POST可以比GET请求更大的数据…一般的回答都是这样.   但是作为一个高端大气上档次的程序员 ...

  4. 转载:Base64编解码介绍

    https://www.liaoxuefeng.com/wiki/897692888725344/949441536192576 Base64是一种用64个字符来表示任意二进制数据的方法. 用记事本打 ...

  5. Redis和Memcached的异同

    Memcached 可以利用多核优势,单实例吞吐量极高,可以达到几十万QPS: 只支持简单的key/value数据结构,不像Redis可以支持丰富的数据类型. 无法进行持久化,数据不能备份,只能用于缓 ...

  6. LeetCode_441. Arranging Coins

    441. Arranging Coins Easy You have a total of n coins that you want to form in a staircase shape, wh ...

  7. LeetCode_437. Path Sum III

    437. Path Sum III Easy You are given a binary tree in which each node contains an integer value. Fin ...

  8. Oracle表存在则删除后再重建

    简单的执行方式: drop table USERINFO; create table USERINFO ( EnglishName ), ChineseName ), Sex ), Age int, ...

  9. [LeetCode] 40. Combination Sum II 组合之和 II

    Given a collection of candidate numbers (candidates) and a target number (target), find all unique c ...

  10. [LeetCode] 131. Palindrome Partitioning 回文分割

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...