安裝為 Maven 構件
您可以將 Liberty 設定檔伺服器安裝為 Maven 構件。 安裝為 Maven 構件有兩個選項:使用 Maven 安裝外掛程式及使用 Liberty 組合包裝方法。
使用 Maven 安裝外掛程式
- 用法:
您可以利用 maven-install-plugin,將包含 Liberty 設定檔伺服器的壓縮保存檔安裝成 Maven 構件。 例如,您可以利用 liberty:package-server 目標來產生壓縮保存檔。
- 範例:使用指令行
mvn install:install-file -Dfile=/opt/ibm/wlp.zip \ -DgroupId=myGroup \ -DartifactId=myServer \ -Dversion=1.0 \ -Dpackaging=zip \
- 範例:使用 pom.xml
- 這是可以在產品的 pom.xml 檔中使用的程式碼 Snippet。
... <plugin> <!-- 將 Liberty 伺服器 zip 安裝在本端 Maven 儲存庫中 --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>2.2</version> <executions> <execution> <id>install-liberty-to-repo</id> <phase>process-resources</phase> <goals> <goal>install-file</goal> </goals> <configuration> <file>/opt/ibm/wlp.zip</file> <groupId>myGroup</groupId> <artifactId>myServer</artifactId> <version>1.0</version> <packaging>zip</packaging> </configuration> </execution> </plugin> ...
使用 Liberty 組合
- 用法:
您可以利用 liberty-assembly 包裝類型,從現有的伺服器安裝架構、壓縮保存檔或另一個伺服器 Maven 構件建立 Liberty 設定檔伺服器 Maven 構件。 任何指定為 Maven compile 相依關係的應用程式,都會隨著組合的伺服器而自動包裝在 dropins/ 目錄中。
- 範例:使用 liberty-assembly 包裝類型
- 這是可以在產品的 pom.xml 檔中使用的程式碼 Snippet。
<project> ... <groupId>myGroup</groupId> <artifactId>myServer</artifactId> <!-- 建立 Liberty 設定檔伺服器組合 --> <packaging>liberty-assembly</packaging> ... <dependencies> <!-- 包裝含有伺服器組合的 SimpleServlet.war --> <dependency> <groupId>wasdev</groupId> <artifactId>SimpleServlet</artifactId> <version>1.0</version> <type>war</type> </dependency> </dependencies> ... <build> <plugins> <!-- 啟用 liberty-maven-plugin --> <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <extensions>true</extensions> <configuration> <serverHome>/opt/ibm/wlp</serverHome> <serverName>test</serverName> </configuration> </plugin> </plugins> </build> ... </project>