Spring Boot 打包成 SDK 去除 application.yaml 配置文件
Spring Boot About 992 wordsMaven pom.xml
在build
节点下,添加resources
节点,并添加excludes
规则,将application.yaml
配置排除在SDK
的jar
包外。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application.yaml</exclude>
</excludes>
</resource>
</resources>
</build>
补充
如果第三方jar
包中包含了application.yaml
或application.properties
,则宿主的Spring Boot
也会使用该配置(但宿主应用定义了相同字段,则以宿主配置为主)。
参考链接
https://docs.spring.io/spring-boot/docs/3.1.5/reference/htmlsingle/#features.external-config
Views: 816 · Posted: 2024-03-27
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...