- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将基于Spring MVC 的maven 项目部署到Tomcat 服务器。我一直在本地模式下使用 eclipse + tomcat 7,项目工作正常,但现在,我购买了一台带有 PLESK 的主机,但该应用程序无法运行。
我使用 Maven 插件方法构建了一个 .WAR(目标全新安装,以及 JDK 1.8 编译器):
我用普通的 wep 应用程序 .war 文件进行测试,并且主机工作正常,因此我认为问题出在构建 .war 文件之前我的项目的结构......但我不知道。
Sample.war 结构:
我目前的结构是这样的(使用 Spring MVC 的 Maven 项目):
我的 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TreeBuk</groupId>
<artifactId>TreeBuk</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
我的 index.jsp 和所有其他 View 都在 WebContent/WEB-INF/views 中。我看到一些示例,其中 index.jsp 在 WebContent/WEB-INF/... 但我不知道为什么...另一方面,我也在本地服务器 tomcat 中测试它(在 eclipse 中没有实例)但不工作部署...我不明白为什么在 tomcat 实例上工作到 eclipse,但在本地 tomcat 服务器不工作。
谁能帮我在服务器上部署我的 wepApp?问题出在哪里?
P.D:我使用的是 Apache Tiles 3.0,一些 .xml 配置文件(security-context.xml、persistence-context.xml、service-context 等)除了 WebContent/WEB- INF/dispatcher-servlet.xml 文件)
编辑 1:当启动执行 apache-tomcat-7.0.67\bin\startip.bat 的本地 tomcat 服务器时,我可以在控制台中看到:
如果我去 url http://localhost:8080/TreeBuk/
编辑 2在我的 web.xml 文件中,我配置了多上下文文件 xml。 (提醒该应用程序适用于 Eclipse 的 tomcat 服务器实例)
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:com/treebuk/config/persistence-context.xml
classpath:com/treebuk/config/service-context.xml
classpath:com/treebuk/config/security-context.xml
classpath:com/treebuk/config/application-context.xml
</param-value>
</context-param>
最佳答案
最后,我不知道发生了什么,但是 .War 的结构是无效的...我用其他有效结构在新的 Spring MVC 项目中重建项目,我可以生成 .war 文件。
抱歉,这还没有一个简单的解决方案。
关于java - 在 Tomcat 7 中部署 Spring MVC + Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46775205/
我是一名优秀的程序员,十分优秀!