【问题标题】:Trying to move to Jetty from Tomcat for testing on workstation, tomcat vs jetty试图从 Tomcat 迁移到 Jetty 以在工作站、tomcat vs jetty 上进行测试
【发布时间】:2012-09-07 15:25:05
【问题描述】:

一段时间以来,我一直在使用 eclipse 和 tomcat 编写 Spring/Web 项目,但现在我开始使用 Maven,我也在考虑使用 jetty 进行工作站测试。

我制作了一个示例网络应用程序,如果我从 eclipse 在 tomcat 上运行它,我会转到 http://localhost:8080/TestJetty/ 但如果我执行 mvn jetty:run 我必须访问它来自 http://localhost:8080/

这是为什么呢?

我也可以设置 Eclipse 来运行码头吗?两者的优缺点是什么

【问题讨论】:

    标签: java spring tomcat maven jetty


    【解决方案1】:

    通常对于 maven jetty 插件的“jetty:run”目标,上下文路径是 /,除非它被 contextPath 配置条目覆盖:

           <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>Your version..</version>
                <configuration>
                    <webApp>
                        <contextPath>/mycontextpath</contextPath>
                    </webApp>
                </configuration>
            </plugin>   
    

    在 Eclipse 中,可能是您的项目名称被用作上下文路径。

    关于利弊,这只是您的舒适程度,我更喜欢命令行,因此通常会使用“mvn jetty:run”在 Eclipse 之外运行它

    【讨论】:

    • 我尝试为 contextPath 添加你的 conf,但没有成功
    • 是的,没有任何问题 - 您是否发现 Spring 项目和 jetty:run 有任何问题?
    • 不确定,可能是因为插件版本 - wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin。这对我很有效
    猜你喜欢
    • 2014-05-24
    • 2012-05-31
    • 2013-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-29
    相关资源
    最近更新 更多