Spring Boot 打包成 SDK 去除 application.yaml 配置文件

Spring Boot About 992 words

Maven pom.xml

build节点下,添加resources节点,并添加excludes规则,将application.yaml配置排除在SDKjar包外。

<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.yamlapplication.properties,则宿主的Spring Boot也会使用该配置(但宿主应用定义了相同字段,则以宿主配置为主)。

参考链接

https://docs.spring.io/spring-boot/docs/3.1.5/reference/htmlsingle/#features.external-config

Views: 356 · Posted: 2024-03-27

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh