【问题标题】:Maven, how to run external Tomcat serverMaven,如何运行外部 Tomcat 服务器
【发布时间】:2012-07-10 14:19:38
【问题描述】:

我有一些问题,我无法解决。 我在 D:/server/tomcat7 中解压缩了 tomcat 服务器,我想从 maven 启动它,以便将来在那里部署我的 WebApp。但我找不到如何配置外部文件夹以运行 tomcat。

如果我在 cmd mvn tomcat:run 中调用,maven 会下载 tomcat 并运行它,但我需要从我上面指定的文件夹启动服务器。

Tnx 寻找答案

【问题讨论】:

    标签: tomcat maven maven-tomcat-plugin


    【解决方案1】:

    您可以尝试使用 maven-exec-plugin 通过 ${CATALINA_HOME}/bin 中的脚本启动/停止 Tomcat:

      <plugin>  
        <groupId>org.codehaus.mojo</groupId>  
        <artifactId>exec-maven-plugin</artifactId>  
        <version>1.1</version>  
        <executions>  
          <execution>  
            <id>stop-tomcat</id>  
            <phase>pre-clean</phase>  
            <goals>  
              <goal>exec</goal>  
            </goals>  
            <configuration>  
            <executable>${tomcat.stop.path}</executable>  
            </configuration>  
          </execution>  
          <execution>  
            <id>start-tomcat</id>  
            <phase>deploy</phase>  
            <goals>  
              <goal>exec</goal>  
            </goals>  
            <configuration>  
            <executable>${tomcat.start.path}</executable>    
            </configuration>  
          </execution>  
        </executions>  
      </plugin>  
    

    【讨论】:

    • 好的,tnx。您能否提供 ${tomcat.stop.path} 的示例
    • tomcat.stop.path 的值应该是停止脚本的绝对路径(这里是 Windows 的可能示例:C:\Progra~1\Tomcat\apache-tomcat-7.0.25\bin \startup.bat)
    • 定义 Tomcat 启动/停止路径属性值的更好地方是用户主目录的 .m2 子目录中 settings.xml 文件的属性部分 - 允许团队成员或构建服务器管理员最简单配置路径值的方法
    【解决方案2】:

    不可能,但我想知道您的用例是什么? 这个插件的目的是避免这种手动安装。

    【讨论】:

      猜你喜欢
      • 2010-10-18
      • 1970-01-01
      • 2018-09-24
      • 1970-01-01
      • 2020-06-10
      • 2015-11-30
      • 2015-10-20
      • 1970-01-01
      • 2014-11-09
      相关资源
      最近更新 更多