美好的一天。Maven。部署到玻璃鱼模块
我使用'mvn clear package glassfish:deploy'从cmd进行部署。只包含项目的应用程序可以使用。但有了子模块,我在部署时遇到了一些麻烦。
这个命令给了我这个错误:
[错误]远程故障:未找到文件:[点击这里项目路径] \目标\ test2.war
[错误]的部署[在此项目路径] \ target \ test2.war失败
如何解决这个问题?
家长的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>test.net</groupId>
<artifactId>test2</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
<name>test2 Maven Webapp</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<glassfishDirectory>${local.glassfish.home}</glassfishDirectory>
<user>admin</user>
<passwordFile>${local.glassfish.passfile}</passwordFile>
<domain>
<name>domain1</name>
<httpPort>8080</httpPort>
<adminPort>4848</adminPort>
</domain>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>target/${project.build.finalName}.war</artifact>
</component>
</components>
<debug>true</debug>
<terse>false</terse>
<echo>true</echo>
</configuration>
</plugin>
</plugins>
<finalName>test2</finalName>
</build>
</project>
Child1 POM:
<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">
<parent>
<artifactId>test2</artifactId>
<groupId>test.net</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>child1</artifactId>
<packaging>war</packaging>
<name>child1 Maven Webapp</name>
<properties>
<deploy.glassfish>true</deploy.glassfish>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
</plugin>
</plugins>
<finalName>child1</finalName>
</build>
</project>
CHILD2 POM:
<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">
<parent>
<artifactId>test2</artifactId>
<groupId>test.net</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>child2</artifactId>
<packaging>war</packaging>
<name>child2 Maven Webapp</name>
<properties>
<deploy.glassfish>true</deploy.glassfish>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
</plugin>
</plugins>
<finalName>child2</finalName>
</build>
</project>
谢谢你的回答。但是对于使用第二种方法进行部署的命令,应该为每个孩子分别执行?在父pom中执行它的原因我有错误,'玻璃鱼'是不正确的前缀 – Evgeniy175
对于第二种方法,您不必指定部署命令。尝试在父级别使用命令'mvn clean install'。这是因为部署相关的东西将由您的poms中的插件代码照顾。另外,您不必为每个模块单独使用deploy命令。你的父母pom会一个一个地触发孩子poms,这会部署孩子的文物。尝试上面的命令,让我知道。 –
它已成功编译,子模块现在包含文件夹“目标”。但没有部署到glassfish – Evgeniy175