Springboot 指定外部配置文件启动

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>*.properties</include>
                </includes>
            </resource>
            <!-- Include other files as resources files. -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>*.properties</exclude>
                </excludes>
            </resource>
        </resources>

pom文件添加配置

第一段<resource>配置声明:在src/main/resources目录下,所有的properties文件是资源文件,properties文件需要被过滤。

第二段<resource>配置声明:在src/main/resources目录下,除了properties文件外的其他文件也是资源文件,但是它们不会被过滤。

通过--spring.config.local指定本地配置文件地址

执行启动命令:java -jar common-server.jar --spring.config.local=application.properties

原文地址:https://www.cnblogs.com/exmyth/p/14419372.html