【问题标题】:Tomcat 7 maven plugin additional context on tomcat7:runTomcat 7 Maven 插件在 tomcat7:run 上的附加上下文
【发布时间】:2012-08-25 03:36:48
【问题描述】:

当我使用 tomcat 7 maven 插件在 eclipse 中运行我的 web 应用程序时,我希望将一个额外的上下文部署到 tomcat。在生产环境中,此上下文使用上下文配置映射到 tomcat 目录之外的目录

 <Context path="/userimages" docBase="C:/test/userimages">
 </Context>

通过这种方式可以在

http://wwww.myhost.com/userimages/test.jpg

我如何在 webapp(eclipse、tomcat7 maven 插件)的开发环境中实现相同的目标? 换句话说,我希望可以通过

访问该文件夹的内容
http://localhost:8080/userimages

http://localhost:8080/myapp/userimages

【问题讨论】:

    标签: eclipse tomcat maven maven-tomcat-plugin


    【解决方案1】:

    你应该配置tomcat7-maven-plugin插件。

    试试这个方法:

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.0</version>
        <configuration>
            <path>your_app_context_path</path>
            <uriEncoding>utf-8</uriEncoding>
        </configuration>
    </plugin>
    

    那么你所有的网址都应该以http://wwww.myhost.com/your_app_context_path/...

    开头

    tomcat7:run 目标的更多可选参数可以在apache tomcat maven plugin document找到

    【讨论】:

      【解决方案2】:

      我找到了一种解决方法,它与我最初想要的不完全一致(使用 tomcat maven 插件发布另一个上下文),但它以某种方式解决了我的问题。我在应用程序的 webapp 文件夹中添加了一个文件夹“userimages”,并在开发时使用该文件夹。我通过在 pom.xml 中使用具有以下配置的“maven-war-plugin”来防止该文件夹进入战争并因此进入生产服务器

       <build>
        ....
        <plugins>
         ....
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-war-plugin</artifactId>
              <version>2.2</version>
              <configuration>
                  <packagingExcludes>userimages/</packagingExcludes>
              </configuration>
          </plugin>
          ....
        </plugins>
        ....
       </build>
      

      还要检查herehere

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-19
        • 1970-01-01
        • 2012-08-11
        • 2012-08-09
        • 2016-11-06
        • 1970-01-01
        相关资源
        最近更新 更多