gpt4 book ai didi

java - 在 Tomcat 7 中部署 Spring MVC + Maven

转载 作者:行者123 更新时间:2023-11-28 23:18:22 31 4
gpt4 key购买 nike

我想将基于Spring MVC 的maven 项目部署到Tomcat 服务器。我一直在本地模式下使用 eclipse + tomcat 7,项目工作正常,但现在,我购买了一台带有 PLESK 的主机,但该应用程序无法运行。

我使用 Maven 插件方法构建了一个 .WAR(目标全新安装,以及 JDK 1.8 编译器): enter image description here

结果: enter image description here

我用普通的 wep 应用程序 .war 文件进行测试,并且主机工作正常,因此我认为问题出在构建 .war 文件之前我的项目的结构......但我不知道。

Sample.war 结构:

enter image description here

我目前的结构是这样的(使用 Spring MVC 的 Maven 项目):

enter image description here

我的 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 服务器时,我可以在控制台中看到: enter image description here

如果我去 url http://localhost:8080/TreeBuk/ enter image description here

编辑 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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com