Moh*_*med 21 java maven-2 cxf maven-plugin maven
我有一个CXF WS项目,我会在另一个项目中使用它,我会在Web项目中使用这个WS,但我不知道如何生成Jar文件.
请你有任何想法或一个例子吗?
谢谢
bma*_*ies 32
maven-war-plugin支持创建一个仅包含类的单独工件.
http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html
请参阅'attachClasses'参数.无需添加jar插件或乱七八糟的包装.只需将war插件添加到pluginManagement并启用它即可.
但是,我担心这不是你想要的.要使用CXF Web服务,您需要一个客户端.要获取客户端,请按照CXF示例中的说明了解如何生成和使用客户端存根.你需要一个单独的maven项目.
小智 21
尝试将此添加到您的构建部分:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>make-a-jar</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
Nil*_*esh 17
将以下内容添加到war项目的pom.xml中.
<attachClasses>true</attachClasses> 配置war插件
<groupId>com.yourorg.foobar</groupId>
<artifactId>hello-world</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>hello</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
将以下内容添加到要导入jar of war项目的项目的pom.xml中
<classifier>classes</classifier> 依赖导入
<dependency>
<groupId>com.yourorg.foobar</groupId>
<artifactId>hello-world</artifactId>
<version>1.0</version>
<classifier>classes</classifier>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是通过财产实现它的一种方法.默认情况下,它会生成一个war文件,当你想要jar时只需设置属性.
mvn install -Dp.type=jar
Run Code Online (Sandbox Code Playgroud)
的pom.xml
<properties>
<p.type>war</p.type>
</properties>
<packaging>${p.type}</packaging>
Run Code Online (Sandbox Code Playgroud)
这应该工作:
<!-- Maven JAR plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-services-provided</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Install the jar locally -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>
${project.build.directory}/${project.artifactId}-${project.version}.jar
</file>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
摘自此博客.
| 归档时间: |
|
| 查看次数: |
49724 次 |
| 最近记录: |