美好的一天。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