gpt4 book ai didi

java - Maven wildfly-maven-plugin 自定义standalone.xml

转载 作者:行者123 更新时间:2023-12-01 22:32:15 25 4
gpt4 key购买 nike

在运行 wildfly-maven-plugin:start 时如何使用自定义 standalone.xml(不仅仅是添加数据源、驱动程序...)?

使用 wildfly-maven-plugin-1.0.2.Final:

<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
...
<execution>
<id>pre-integration-phase</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
</execution>
...

我曾尝试使用 maven-resources-plugin 在 wildfly 配置文件夹中复制资源 (standalone.xml),但似乎 wildfly:start 覆盖并删除了 Wildfly 中的所有(其他)文件(配置)目录。

此任务用于 jenkins 集成测试,这就是为什么我需要在测试进行时运行 jboss。

最佳答案

您可以解压 WildFly 安装,然后在 wildfly-maven-plugin 中设置 jbossHome 配置元素。

示例配置:

    <version.wildfly>8.2.0.Final</version.wildfly>
<jboss.home>${project.build.directory}/wildfly-${version.wildfly}</jboss.home>
<server.config>standalone.xml</server.config>


<!-- Unpack the distribution -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-wildfly</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<inherited>false</inherited>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${version.wildfly}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<!-- Copy server configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${version.plugin.resources}</version>
<executions>
<execution>
<id>copy-standalone-xml</id>
<phase>generate-test-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${jboss.home}/standalone/configuration</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- WildFly plugin to deploy war -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<configuration>
<jbossHome>${jboss.home}</jbossHome>
<serverConfig>${server.config}</serverConfig>
</configuration>
<executions>
<execution>
<id>pre-integration-phase</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>

关于java - Maven wildfly-maven-plugin 自定义standalone.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29118479/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com