window下绝对路径

项目中配置文件(properties或yml)和项目是分离的,常见的配置方法如下:

    <profiles>
        <profile>
            <id>mas</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <maven.properties.mas_properties_path>file:/opt/pay/config/mas/mas_v2.properties</maven.properties.mas_properties_path>
            </properties>
        </profile>
        <profile>
            <id>mas4pos</id>
            <properties>
                <maven.properties.mas_properties_path>file:/opt/pay/config/pos/mas4pos/mas_v2.properties</maven.properties.mas_properties_path>
            </properties>
        </profile>
    </profiles>

指定配置文件的路径是:

file:/opt/pay/config/mas/mas_v2.properties

如果是linux系统,很好理解,/就是根目录,直接找/opt/pay/config/mas/mas_v2.properties即可

如果是window系统,则这个绝对路径的配置如下:

  • 如果是内嵌tomcat启动或者是springBoot的启动方式,/代表的根目录就是项目工程所在根目录(比如工程目录是:D:\workspace\mas,则配置文件:D:\opt\pay\config\mas\。。。)
  • 如果通过tomcat发布后启动,/代表的根目录就是tomcat所在根目录(比如工程目录是:D:\workspace\mas,Tomcat所在目录是C:\tomcat7,则配置文件以tomcat所在目录为准:C:\opt\pay\config\mas\。。。)

严禁在配置中指定window的绝对路径,就是用/代表根目录

猜你喜欢

转载自www.cnblogs.com/huahua035/p/8919133.html