簡體   English   中英

適用於 Windows 和 Linux 平台的 Spring Boot 應用程序的 Maven 構建

[英]Maven build for Spring boot Application for windows and linux platforms

我需要使用 Maven 構建為 windows 和 linux 平台生成我的 Spring Boot 應用程序二進制文件。

我計划為 windows 和 linux ie 有兩個不同的 application.properties

  • 應用程序windows.properties
  • 應用程序-linux.properties

在 pom.xml 我會有這個

<profile>
    <id>dev</id>
    <properties>
        <activatedProperties>windows</activatedProperties>
    </properties>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
</profile>
<profile>
    <id>release</id>
    <properties>
        <activatedProperties>linux</activatedProperties>
    </properties>
</profile>

Maven 構建將使用 Jenkins 觸發。但通過這種方式,我一次只能激活一個配置文件,因此 Windows 和 linux 將需要兩個 jenkins 項目。 有沒有更好的方法來做到這一點?

應該通過在啟動 spring boot 應用程序時提供構建參數來選擇配置文件。

-Dspring.profles.active=$profile

如果您使用 jenkins 啟動應用程序,只需在作業執行期間添加一個選項來選擇配置文件,該選項可以向應用程序添加參數。

https://docs.spring.io/spring-boot/docs/1.1.6.RELEASE/reference/html/boot-features-profiles.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM