Maven覆盖和Eclipse [英] Maven overlays and Eclipse
问题描述
在A的pom.xml中,我有:
<依赖关系>
<依赖关系>
< groupId> com.mygroup< / groupId>
< artifactId> B< / artifactId>
< version> 1.0-SNAPSHOT< / version>
< type> war< / type>
< scope> compile< / scope>
< / dependency>
< / dependencies>
< build>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 2.0.2< / version>
< 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.1.1< / version>
< / plugin>
< / plugins>
< / build>
我有两个问题:
-
在B中进行一些更改时,如果我在AI上运行maven构建,则不会看到导致的爆炸档案中的更改。
-
尝试从Eclipse部署A不起作用 - B的内容不包括在生成的war /爆炸档案中。
感谢您的帮助。
嗯,如果你修改B中的内容,将其安装到您的本地maven repo( mvn install
)中,将其作为依赖关系的其他本地项目接收最新修改。
当构建maven项目时,最好使用Maven(如使用诸如 mvn package
等命令)构建它,而不使用其他构建工具(如Eclipse )。如果你想建立一个la Maven,但是从Eclipse GUI的舒适性,你可以从以下位置获取m2_eclipse插件:
http://m2eclipse.sonatype.org/installing-m2eclipse.html
它将Maven与Eclipse集成。然后,当您在Eclipse中单击项目时,在运行...选项下,您将拥有允许您将Maven构建的项目,将所有控制台输出重定向到Eclipse控制台窗口。
作为最后一个注释,在诸如上述的设置中,理想情况下,您将创建一个父项Maven项目(打包为pom),该项目具有子项目B和A(以该顺序)。这样,如果您在两个项目中修改了内容,并且希望使用最新的modif来构建所有内容,那么您只需在父pom上进行maven安装即可.Maven将负责处理所有内容。
I have 2 Maven web projects A and B. B contains some common parts and A depends on B.
In A's pom.xml I have:
<dependencies>
<dependency>
<groupId>com.mygroup</groupId>
<artifactId>B</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<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.1.1</version>
</plugin>
</plugins>
</build>
I have 2 problems:
When making some changes in B, if I run a maven build on A I don't see the changes in the resulting exploded archive.
Trying to deploy A from Eclipse does not work - the contents of B are not included in the resulting war/exploded archive.
Thanks for your help.
Well, if you changes stuff in B, you have to re-install it into your local maven repo (mvn install
) for other local projects that have it as dependency to receive the latest modifications.
When building a maven project it's best if you build it using Maven (like with commands such as mvn package
) and not using some other building tool (such as Eclipse). If you wanna build it a la Maven but from the comfort of your Eclipse GUI, you can istall m2_eclipse plugin from :
http://m2eclipse.sonatype.org/installing-m2eclipse.html
which integrates Maven with Eclipse. Then, when you rigth click on your project in Eclipse, under the "Run..." options you'll have the one that allows your to Maven build it, redirecting all console output to the Eclipse console window.
And as a final note, in a setup such as the one aboce, ideally you'd create a parent Maven project (packaged as "pom") which has as child projects B and A (in that order). This way if you've modified stuff in both projects and you want everything to be build with the latest modifs, you can just do a maven install on the parent pom and Maven will take care of everything.
这篇关于Maven覆盖和Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!