Java Maven ClassNotFoundException SpringServletContainerInitializer

Java Maven ClassNotFoundException SpringServletContainerInitializer,java,spring,maven,Java,Spring,Maven,我一直在努力解决这个错误大约3个小时。为了达到这一点,我不得不重新创建这个项目大约6次。我在caveofprogramming.com上关注Spring教程,无法完成这一步 以下是错误: SEVERE: Failed to detect ServletContainerInitializers for context with name [/springagain] java.io.IOException: java.lang.ClassNotFoundException: org.spring

我一直在努力解决这个错误大约3个小时。为了达到这一点,我不得不重新创建这个项目大约6次。我在caveofprogramming.com上关注Spring教程,无法完成这一步

以下是错误:

SEVERE: Failed to detect ServletContainerInitializers for context with name [/springagain] java.io.IOException: java.lang.ClassNotFoundException: org.springframework.web.SpringServletContainerInitializer
at org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappServiceLoader.java:200)
at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:158)
at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1579)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1280)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:888)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:388)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5522)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.springframework.web.SpringServletContainerInitializer
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappServiceLoader.java:197)
... 15 more
web.xml很抱歉设置格式,网站不希望我正确设置格式:

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
 <display-name>springagain</display-name> <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>


</welcome-file-list> <servlet>
<description></description>
<display-name>offers</display-name>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/</url-pattern> </servlet-mapping> </web-app>
offers-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> </beans>

我所做的一切都不能使我接近工作。是部署程序集、我拥有的依赖项以及它说在依赖项中找不到的类的相册

在进行了一些searvh之后,我发现与spring framework 4.1.9.RELEASE相关的问题在更新到4.0.5.RELEASE之后得到了解决

然后,如果您查看OP中发布的图片,就会看到这一点,这表明这一点已经完成,并且不起作用。这些教程似乎已经严重过时。除非您有特别迫切的需要使用传统设置,否则请使用Spring Boot,您可以在IntelliJ和STS中提供的向导中自动生成完整的工作项目。@chrylis我正在尝试构建一个Hibernate项目,本系列教程采用一步一步的方法,使用MySQL构建一个web MVC应用程序,然后最终使用Hibernate替换所有SQL功能。我想用这些来学习如何达到Hibernate项目的最终目标。是的,但它是一步一步地使用完全过时的技术。您可以转到Spring Initializer,检查Web和数据JPA,就完成了。您甚至不必编写JPA/Hibernate查询;Spring会为您做这件事。这看起来确实很有用,但是它没有提供链接到本地服务器所需的信息或任何有关查询的信息。我没有意识到这些教程已经过时了,它们在专门用于学习的SUB中被强烈推荐到Reddit上。在tomcat/web应用程序出现之前,一切正常。