我正在开发一个maven多模块应用程序,它由两个模块组成:
的webapp 我的项目结构如下:
-(root)pom
-Common
-Webapp
我们正在使用带有S2I(源到映像)部署的openshift Web控制台。我们选择的图像是Jboss Eap。提供git存储库后,Openshift开始创建所需的资源。它使用maven成功编译和安装我们的模块,但是它没有将它部署在Jboss的独立文件夹中。查看构建日志,我们可以在日志结束时检查所有正在检索的依赖项和BUILD SUCCESS。但是没有在image jboss文件夹上部署工件。我们可以通过查看日志或使用控制台来检查pod文件来确认这一点。
这个项目是在bitbucket
Root pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>:: Parent ::</name>
<description>Parent POM for some app</description>
<modules>
<module>Common</module>
<module>Webapp</module>
</modules>
</project>
普通pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.test.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.test.common</groupId>
<artifactId>Common</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Common module</name>
<description>Module for common elements that exist between projects</description>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- Compiler plugin enforces Java 1.8 compatibility and activates annotation
processors -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
...
</dependencies>
</project>
最后,网络pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.test.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.test.external</groupId>
<artifactId>Webapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name> Web</name>
<description>web module</description>
<properties>
<!-- Explicitly declaring the source encoding eliminates the following
message: -->
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- JBoss dependency versions -->
<version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>
<version.jboss.spec.javaee.7.0>1.0.3.Final</version.jboss.spec.javaee.7.0>
<!-- other plug-in versions -->
<version.war.plugin>2.1.1</version.war.plugin>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<build>
<!-- Set the name of the WAR, used as the context root when the app
is deployed -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
...
<dependency>
<groupId>com.test.common</groupId>
<artifactId>Common</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
有没有人设法实现这一目标?
答案 0 :(得分:2)
我认为有一种更好的方式,即在您的网络中使用openshift配置文件。这可以追溯到在V2中完成的方式。在将在构建期间调用的openshift配置文件中,将.war文件复制到部署目录中。我注意到的唯一区别是部署目录名为target
而不是webapps
,但由于target
似乎有效,我没有做任何详细的测试。 E.g:
<profiles>
<profile>
<!-- When built in OpenShift the openshift profile will be used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app will need. -->
<!-- By default that is to put the resulting archive into the deployments folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different environments.html -->
<id>openshift</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<outputDirectory>target</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
答案 1 :(得分:0)
我最终使用maven-antrun-plugin将war复制到jboss独立文件夹中。
Array [ <10 empty slots>]