java - 未找到 Servlet-Context : Spring 4 Hibernate 4 Maven JSF PrimeFaces in NetBeans

标签 java spring hibernate maven netbeans-8

开始: - 我是 J2e 的初学者,这种组合对于功能强大的应用程序来说几乎是完美的,而且对于破坏 J2e 启动器来说也是完美的。 - 我搜索了很多答案,但没有,没有人纠正这个问题。

就这么简单: - 我在 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>

关于java - 未找到 Servlet-Context : Spring 4 Hibernate 4 Maven JSF PrimeFaces in NetBeans,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32147782/

相关文章:

java - hibernate @ManyToMany,错误: relation does not exists

java - 一级缓存不适用于 JPA 和 Hibernate

java - Play框架持久单元

java - writer.dispose() 未按预期工作

java - 不在 spring MVC 中渲染汉字

java - 使用 Web 服务客户端 JAXB 生成的类作为 JPA 实体

java - Spring Redis 在使用@Cacheable 或@CachePut 时将 POJO 保存为不同的类型

java - 监控分布在多台服务器上的一个应用程序

mysql - 如何将数据库(MySQL)中的[名称,值]对存储在表的单个列/字段中?

java - JBoss 启动缓慢,可能与指向 Heroku Postgres 的数据源有关