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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM