【问题标题】:How to deploy to WebSphere Liberty apps directory from WebSphere Liberty Maven plugin?如何从 WebSphere Liberty Maven 插件部署到 WebSphere Liberty 应用程序目录?
【发布时间】:2017-05-24 03:31:34
【问题描述】:

我有一个在 WebSphere liberty 中运行的应用程序。通过 mvn install 命令,我需要将我的应用程序部署到 liberty apps 目录,因为我没有使用 dropins 目录。

Bellow 是我可以部署到 dropins 目录的工作 maven 插件代码。

        <plugin>
            <groupId>net.wasdev.wlp.maven.plugins</groupId>
            <artifactId>liberty-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>start-server</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start-server</goal>
                    </goals>
                    <configuration>
                        <verifyTimeout>60</verifyTimeout>
                    </configuration>
                </execution>
                <execution>
                    <id>deploy</id>
                    <phase>install</phase>
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <serverHome>${wlp.dir}</serverHome>
                <serverName>${server}</serverName>
                <appArtifact>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>${project.artifactId}</artifactId>
                    <version>${project.version}</version>
                    <type>${project.packaging}</type>
                </appArtifact>
                <appDeployName>${project.artifactId}.${project.packaging}</appDeployName>
            </configuration>
        </plugin>

我在任何地方都找不到需要添加/更改哪些配置才能将应用程序直接部署到应用程序目录。有人可以让我知道这里缺少什么吗?

【问题讨论】:

  • 基于 github repo doc (github.com/WASdev/ci.maven/blob/master/docs/deploy.md#deploy) 听起来只能部署到dropins。为什么需要部署到apps目录而不是dropins?共享库什么的?
  • 是的。我不能共享库,这会导致我的应用程序出现一些问题。因此我别无选择,只能使用应用程序目录
  • 您可以将共享库应用到“dropin 应用程序”,方法是将 jar 放在以下位置:${shared.config.dir}/lib/global${server.config.dir}/lib/global。请参阅此文档:ibm.com/support/knowledgecenter/SSAW57_8.5.5/…
  • 我一直在使用 ${shared.config.dir}/lib/global,直到遇到错误 oracle/sql/ArrayDescriptor。它是由 ojdbc6.jar 引起的。一旦我将应用程序放入应用程序文件夹并在 server.xml 中手动将 libs 目录配置分配给应用程序并在 server.xml 中使用相同的 libs 目录配置来创建数据源,问题就解决了。

标签: maven ant maven-plugin websphere-liberty liberty-maven-plugin


【解决方案1】:

添加 install-apps 执行步骤而不是 deploy(部署执行步骤只会将应用程序部署到 dropins 文件夹)步骤将解决问题。 版本必须更新到 1.3,这是目前最新的

参考:https://github.com/WASdev/ci.maven/blob/master/docs/install-apps.md

完整的maven插件代码如下

<plugin>
        <groupId>net.wasdev.wlp.maven.plugins</groupId>
        <artifactId>liberty-maven-plugin</artifactId>
        <version>1.3</version>
        <executions>
            <execution>
                <id>start-server</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>start-server</goal>
                </goals>
                <configuration>
                    <verifyTimeout>60</verifyTimeout>
                </configuration>
            </execution>
            <execution>
                <id>install-apps</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>install-apps</goal>
                </goals>
                <configuration>
                    <appsDirectory>apps</appsDirectory>
                    <installAppPackages>project</installAppPackages>
                </configuration>
            </execution>
        </executions>
        <configuration>
            <serverHome>${wlp.dir}</serverHome>
            <serverName>${server}</serverName>
            <appArtifact>
                <groupId>${project.groupId}</groupId>
                <artifactId>${project.artifactId}</artifactId>
                <version>${project.version}</version>
                <type>${project.packaging}</type>
            </appArtifact>
            <appDeployName>${project.artifactId}.${project.packaging}</appDeployName>
        </configuration>
    </plugin>

【讨论】:

    【解决方案2】:

    您也可以尝试该插件的当前 2.0-SNAPSHOT 版本。只需包含父 pom 和插件的一些配置。 2.0 版将于 6 月初发布。

    如果您不想包含父 pom,您可以从包含 liberty-maven-plugin 目标绑定到 Maven 默认构建生命周期的父 pom 中复制 &lt;pluginManagement/&gt; 部分。见https://github.com/WASdev/ci.maven/blob/master/docs/parent-pom.md

    <parent>
        <groupId>net.wasdev.wlp.maven.parent</groupId>
        <artifactId>liberty-maven-app-parent</artifactId>
        <version>2.0-SNAPSHOT</version>
    </parent>
    
    <repositories>
        <repository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/
            </url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/
            </url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
             </snapshots>
        </pluginRepository>
    </pluginRepositories>
    
    ...
    
    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            ...
            <plugin>
                <groupId>net.wasdev.wlp.maven.plugins</groupId>
                <artifactId>liberty-maven-plugin</artifactId>
                <version>2.0-SNAPSHOT</version>
                <configuration>
                    <assemblyArtifact>
                        <groupId>com.ibm.websphere.appserver.runtime</groupId>
                        <artifactId>wlp-webProfile7</artifactId>
                        <version>17.0.0.1</version>
                        <type>zip</type>
                    </assemblyArtifact>
                    <serverName>${project.artifactId}Server</serverName>
                    <configFile>src/main/liberty/config/server.xml</configFile>
                </configuration>
            </plugin>
        </plugins>
    
        ...
    </build>
    

    【讨论】:

      猜你喜欢
      • 2017-06-16
      • 1970-01-01
      • 2020-07-20
      • 2016-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-13
      • 2016-11-23
      相关资源
      最近更新 更多