概述
使用maven工具构建项目,需要打包后通过axis2发布webservice。使用axis2发布需要把依赖的jar添加到指定文件夹下,大量的依赖不能通过手工一个一个导出。需要借助maven插件工具。
操作
- 在pom中添加插件引用依赖
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<excludeArtifactIds>
junit
</excludeArtifactIds>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
将工程依赖导出到编译目录下的/lib文件夹中。其中还设置了排除依赖junit,这个在发布时是不需要的。
- 执行命令
mvn clean package -Dmaven.test.skip=true
执行清理并打包(自动编译),同时跳过测试用例的执行。
- 结果
在target/lib目录下找到复制出的项目依赖