我用eclipse创建了一个 HelloWorld REST Web服务器。我用Eclipse创建了一个动态Web项目,我将项目转换为maven项目......当我用eclipse运行项目时,一切正常。知道我想用命令行运行项目。我安装了maven然后运行{{1}}。它构建成功。之后我该怎么办?
答案 0 :(得分:0)
您应该在服务器上部署创建的战争,以便开始使用它。在maven中,可以使用cargo-maven2-plugin
完成。
此类货物部署示例如下所示:
<!--
Plugin to initiate instance of tomcat server
-->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.9</version>
<inherited>false</inherited>
<configuration>
<wait>true</wait>
<container>
<containerId>tomcat7x</containerId>
<zipUrlInstaller>
<url>
http://apache.mirror1.spango.com/tomcat/tomcat-7/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip
</url>
<downloadDir>
${project.build.directory}/downloads
</downloadDir>
<extractDir>
${project.build.directory}/extracts
</extractDir>
</zipUrlInstaller>
<type>installed</type>
<dependencies>
<dependency>
<groupId>org.jboss.narayana.jta</groupId>
<artifactId>narayana-jta</artifactId>
</dependency>
<dependency>
<groupId>org.uniknow.tomcat</groupId>
<artifactId>narayana-tomcat-listener
</artifactId>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
</dependencies>
<!--<log>${project.build.directory}/logs/tomcat.log</log>-->
<!--<output>${project.build.directory}/logs/tomcat.out-->
<!--</output>-->
</container>
<!-- Configuration web server -->
<configuration>
<type>standalone</type>
<home>${project.build.directory}/tomcat</home>
<properties>
<!--<cargo.logging>high</cargo.logging>-->
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.rmi.port>8206</cargo.rmi.port>
<cargo.tomcat.ajp.port>8010</cargo.tomcat.ajp.port>
</properties>
<files>
<copy>
<file>${basedir}/src/config/server.xml</file>
<todir>conf</todir>
<configfile>true</configfile>
<overwrite>true</overwrite>
</copy>
<copy>
<file>${basedir}/src/config/context.xml</file>
<todir>conf</todir>
<configfile>true</configfile>
<overwrite>true</overwrite>
</copy>
</files>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</plugin>
这是您可以在tutorials/rest
找到的项目的一部分