将使用Eclipse和Maven创建的项目部署到Tomcat [英] Deploying project, created with Eclipse and Maven, to Tomcat

查看:220
本文介绍了将使用Eclipse和Maven创建的项目部署到Tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Eclipse 3.5,Maven 2,m2eclipse和Tomcat 6.所以我为原型webapp创建Maven项目。
这是pom.xml:

 < project xmlns =http://maven.apache.org/ POM / 4.0.0xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0。 0 http://maven.apache.org/maven-v4_0_0.xsd\">
< modelVersion> 4.0.0< / modelVersion>
< groupId> com.itransition< / groupId>
< artifactId> hello< / artifactId>
< packaging> war< / packaging>
< version> 0.0.1-SNAPSHOT< / version>
< name> hello Maven Webapp< / name>
< url> http://maven.apache.org< / url>

<! - tools.jar依赖关系 - >
<个人资料>
<个人资料>
< id> default-tools.jar< / id>
< activate>
< property>
< name> java.vendor< / name>
< value> Sun Microsystems Inc.< / value>
< / property>
< / activation>
<依赖关系>
<依赖关系>
< groupId> com.sun< / groupId>
< artifactId> tools< / artifactId>
< version> 1.5.0< / version>
< scope> system< / scope>
< systemPath> $ {java.home} /../ lib / tools.jar< / systemPath>
< / dependency>
< / dependencies>
< / profile>
< / profiles>
<依赖关系>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 3.8.1< / version>
< scope> test< / scope>
< / dependency>
<依赖关系>
< groupId> org.apache.struts< / groupId>
< artifactId> struts2-core< / artifactId>
< version> 2.1.8.1< / version>
< / dependency>
< / dependencies>

< build>
< finalName> hello< / finalName>
< / build>
< / project>

所以我想将我的Web应用程序部署到Tomcat。我需要做什么? Maven安装没有帮助。但是,如果我通过Maven安装来创建战争,我可以将其导入eclipse并通过服务器弹出窗口中的添加和删除...将其部署到Tomcat。

解决方案

可以通过使用Maven的Tomcat插件来解决此问题。其主页有关于插件的配置的详细信息,部署战争文件


I'm using Eclipse 3.5, Maven 2, m2eclipse and Tomcat 6. So i create Maven project for archetype webapp. This is pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">  
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.itransition</groupId>
    <artifactId>hello</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>hello Maven Webapp</name> 
    <url>http://maven.apache.org</url>

    <!-- tools.jar dependency -->    
    <profiles>
        <profile>
            <id>default-tools.jar</id>
            <activation>
                <property>
                    <name>java.vendor</name>
                    <value>Sun Microsystems Inc.</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>1.5.0</version>
                    <scope>system</scope>
                    <systemPath>${java.home}/../lib/tools.jar</systemPath>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.1.8.1</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>hello</finalName>
    </build>
</project>

So then i want to deploy my web application to Tomcat. What I need to do? Maven install don't help. But if I create war by Maven install, i can import it to eclipse and deploy it to Tomcat by "Add and remove..." in server popup.

解决方案

This problem can be resolved by using the Tomcat plugin for Maven. Its homepage has got extensive documentation concerning the configuration of the plugin and deployment of war files.

这篇关于将使用Eclipse和Maven创建的项目部署到Tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆