【问题标题】:component-scan not working on jar file组件扫描不适用于 jar 文件
【发布时间】:2015-07-31 05:43:59
【问题描述】:

springmvc-context.xml 配置文件

Jar 放在 WEB-INF/lib 中。 它在尝试访问控制器时给出 404。如何判断其是否启动以及进一步的工作。

【问题讨论】:

标签: java spring web-applications


【解决方案1】:

尝试放置:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
</dependency>

pom.xml 文件中用于 spring-context jar 的此依赖项。

但在此之前,您已将 jar 文件从 WEB-INF/lib 放置到构建路径。如果不是首先将jar放在项目的构建路径中。

这可能会有所帮助。谢谢!!!

【讨论】:

  • spring-context-support-4.1.6.RELEASE jar 在类路径中。我们的项目不包含 pom。
  • 的 application-context.xml 限制了它进行扫描。它在层次结构中高于 servlet-context.xml。将其更改为 工作正常。
猜你喜欢
  • 1970-01-01
  • 2018-05-12
  • 1970-01-01
  • 2017-02-27
  • 2014-12-26
  • 2012-03-16
  • 2013-12-03
  • 2016-10-21
  • 2019-03-29
相关资源
最近更新 更多