我对maven很陌生;我需要在两个不同的目录中编译和打包2 war文件,即使源代码是相同的(只更改web.xml文件)。
试着更好地解释:
LT目录结构:
<DIR> LT1_war
<DIR> LT_war
pom.xmlpom的一部分是:
<modules>
<module>LT_war</module>
<module>LT1_war</module>
</modules>
inside the folder LT_war there is a pom and src-->main-->java
resources
webapp此编译成功,我还将其打包到war LT_war (部署到tomcat)中。
我需要一种方法来在目录LT1_war内编译(使用LT_war目录中的源代码),并使用LT_war目录内的webapp进行打包(只需更改web.xml文件)。
我试着在目录LT1_war中编写pom,但是当我午餐mvn打包时,它告诉我:
[INFO] lt ................................................ SUCCESS [3.995s]
[INFO] LT ................................................ SUCCESS [1:12.629s]
[INFO] LT1 ............................................... FAILURE [41.367s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:59.716s
[INFO] Finished at: Tue Jul 08 23:50:43 CEST 2014
[INFO] Final Memory: 20M/200M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.0:war (default-war) on project LT1: Error assembling WAR: Deployment descriptor: D:\attivi
taTomcat7\LT\LT1_war\target\LT1\WEB-INF\web.xml does not exist. -> [Help 1]:这是LT1_war中pom文件的一部分:
<build>
<finalName>LT1</finalName>
<resources>
<resource>
<directory>../LT_war/src/</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<excludes>**/.svn/**</excludes>
</configuration>
<executions>
<execution>
<id>exploded</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
<execution>
<id>war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>发布于 2014-07-08 23:31:49
有几件事我很高兴地认为你所做的事情是非常错误的:
.svn文件夹(现在在Subversion工作空间的根部只有一个.svn文件夹,不会影响Maven WAR插件)所以您的项目结构可能如下所示:
ROOT
MEAT (packaging JAR, where your classes live)
LT (packaging WAR, depends on MEAT)
LT1 (packaging WAR, depends on MEAT, and stays the heck out of LT)加法(如评论中所指出的,忘记了某些方面).
虽然肉是包装罐的,但你希望它也包括你已经进入webapp的东西,而不是在类路径上结束。如果您使用的是最近的servlet-api,这可以通过提供一个资源文件夹来实现,如下所示:
src/main/resources/META-INF/resources/...例如,.../META-INF/resources/flower.jpeg将以<context root>/flower.jpg的形式出现在部署的WAR中(而不是仅仅添加到<context root>/flower.jpg类路径中)。
发布于 2014-07-09 00:32:14
我需要一种方法来在目录LT1_war内编译(使用LT_war目录中的源代码),并使用LT_war目录内的webapp进行打包(只需更改web.xml文件)。
通常,您从根目录编译。做您要做的事情并不方便,但是可以使用--also-make命令行选项来完成。
https://stackoverflow.com/questions/24642249
复制相似问题