liugang0503
V2EX  ›  问与答

properties 文件中定义了个常量,其它的属性也引用到了这个常量,后台 Java 代码获取属性值不对,该如何解析呢?

  •  
  •   liugang0503 · Sep 7, 2018 · 1199 views
    This topic created in 2812 days ago, the information mentioned may be changed or developed.

    形如: URL_PREFIX=http://127.0.0.1:9001 CALL_URL=${URL_PREFIX}/aa/bb.do

    后台解析的还是 ${URL_PREFIX}/aa/bb.do 这样,占位符中的内容没有替换。

    后台解析主要代码: private static Properties props ; public ConfigProperties(){ try { Resource resource = new ClassPathResource("/interface.properties"); props = PropertiesLoaderUtils.loadProperties(resource); } catch (IOException e) { e.printStackTrace(); } }

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5746 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 06:18 · PVG 14:18 · LAX 23:18 · JFK 02:18
    ♥ Do have faith in what you're doing.