未找到 Servlet 上下文:Spring 4 Hibernate 4 Maven JSF PrimeFaces in NetBeans

Servlet-Context not found : Spring 4 Hibernate 4 Maven JSF PrimeFaces in NetBeans

开始: - 我是 J2e 的初学者,这种组合对于强大的应用程序来说几乎是完美的,但对于 J2e 初学者来说也是完美的。 - 我搜索了很多答案,但没有,none 更正了这一点。

就这么简单: - 我在 Netbeans 8 和 Eclipse Mars 之间重复创建应用程序 8 次,我拥有所有依赖项。问题出在 Servlet-Context 上。 Tomcat 抛出一个 FileNotFound 错误,一旦我删除它:

    <listener>
   <listener-class>
           org.springframework.web.context.ContextLoaderListener
   </listener-class>
 </listener>
 <listener>
   <listener-class>
           org.springframework.web.context.request.RequestContextListener
   </listener-class>
</listener>

它有效但不显示来自数据库的数据,(我的整个应用程序现在是关于在数据库上显示 id = 1 的用户 ID。)

Tomcat中的错误:

    org.apache.catalina.core.StandardContext.listenerStart Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
 org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

有人可以帮忙吗?

尝试将 contextConfigLocation 添加到您的 web.xml 以便它可以找到您的 applicationContext.xml 文件。

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>
     <listener>
   <listener-class>
           org.springframework.web.context.request.RequestContextListener
   </listener-class>
</listener>

删除它就可以了。 Spring 4个问题。