eclipse - tomcat7 :run 上的 Tomcat 7 maven 插件附加上下文

标签 eclipse tomcat maven maven-tomcat-plugin

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

 <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

最佳答案

你应该配置 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/...

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

关于eclipse - tomcat7 :run 上的 Tomcat 7 maven 插件附加上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12196353/

相关文章:

java - 什么会使 Ant 在 Eclipse 中使用 UTF-8 而不是我的系统默认 Cp1252 执行 'javac'?

eclipse - 我的删除键在 OS X 的 Eclipse 中不起作用

spring - 如何使用 hibernate 和 spring 在 Tomcat 7 中配置 MySQL 数据源?

java - 目标运行时 WildFly 在 maven 测试后解包

java - 如何解决这些 AWS 导入问题?

Eclipse CDT,不能使用调试器(始终停留在89%的进程上)

android - 默认选择为空的微调器

java - Q : I can't start Database connection in Eclipse

java - 为什么 "request.getUserPrincipal().getName()"有时会返回一个空字符串?

java - 从命令行运行 Apache CXF 客户端