【问题标题】:Maven: put dependent jar to different war folder instead of war/web-inf/libMaven:将依赖的 jar 放到不同的 war 文件夹而不是 war/web-inf/lib
【发布时间】:2011-05-15 00:53:09
【问题描述】:

目前我正在尝试为基于axis2的项目制作maven构建任务。
在我的pom.xml 中,我定义了依赖 jar 文件。我希望当战争开始时,jar 将被移动到另一个目录:不是在war/web-inf/lib,而是war/web-inf/servicejars

我查看了有关 stackoverflow 的类似问题,但没有帮助。

    <dependencies>
        <dependency>
            <groupId>mycompany</groupId>
            <artifactId>MyService</artifactId>
            <!-- didnt work for me -->
            <!--<properties>-->
                <!--<war.target.path>servicejars</war.target.path>-->
            <!--</properties>-->
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.5.2</version>
        </dependency>
        <!-- etc ... -->
    </dependencies>
    <build>
        <finalName>Axis2</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                </configuration>
                <extensions>true</extensions>
            </plugin>
            <!--<plugin> Didn't worked too-->
                <!--<groupId>org.apache.maven.plugins</groupId>-->
                <!--<artifactId>maven-dependency-plugin</artifactId>-->
                <!--<version>2.1</version>-->
                <!--<executions>-->
                    <!--<execution>-->
                        <!--<id>copydep</id>-->
                        <!--<phase>prepare-package</phase>-->
                        <!--<goals>-->
                            <!--<goal>copy-dependencies</goal>-->
                        <!--</goals>-->
                        <!--<inherited>false</inherited>-->
                        <!--<configuration>-->
                            <!--<includeArtifactIds>MyService</includeArtifactIds>-->
                            <!--<outputDirectory>$project.build.directory/${project.build.finalName}/web-inf/servicejars</outputDirectory>-->
                        <!--</configuration>-->
                    <!--</execution>-->
                <!--</executions>-->
            <!--</plugin>-->
        </plugins>
    </build>

提前致谢。

【问题讨论】:

  • i want that when war is building, the jar will be moved to another directory: not in war/web-inf/lib but to war/web-inf/servicejars 这是有原因的吗?为什么不让 maven 处理依赖关系?
  • 实际上我需要将其部署为axis2服务。如果它可以通过一些插件来完成 - 那就更好了。

标签: web-services maven-2 maven axis2


【解决方案1】:

看看Maven assembly plugin。您可以使用assembly descriptor filedir 格式执行此操作。可能不是您要寻找的示例,但一个很好的起点是他们随插件文档提供的示例:http://maven.apache.org/plugins/maven-assembly-plugin/examples/single/including-and-excluding-artifacts.html

这里有一个很好的链接到程序集描述符模型的外观:http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

【讨论】:

    猜你喜欢
    • 2011-06-25
    • 2014-04-23
    • 2019-09-19
    • 1970-01-01
    • 2011-03-26
    • 1970-01-01
    • 2020-10-05
    • 2018-02-24
    • 1970-01-01
    相关资源
    最近更新 更多