作为 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 文件中的代码段。
... <plugin> <!-- Install the Liberty server zip into the local Maven repository --> <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 组合件打包类型
- 这是可以用在项目的 pom.xml 文件中的代码段。
<project> ... <groupId>myGroup</groupId> <artifactId>myServer</artifactId> <!-- Create Liberty profile server assembly --> <packaging>liberty-assembly</packaging> ... <dependencies> <!-- Package SimpleServlet.war with server assembly --> <dependency> <groupId>wasdev</groupId> <artifactId>SimpleServlet</artifactId> <version>1.0</version> <type>war</type> </dependency> </dependencies> ... <build> <plugins> <!-- Enable 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>