Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法从外部jar文件加载spring配置xml_Java_Spring_Spring Mvc_Spring Integration - Fatal编程技术网

Java 无法从外部jar文件加载spring配置xml

Java 无法从外部jar文件加载spring配置xml,java,spring,spring-mvc,spring-integration,Java,Spring,Spring Mvc,Spring Integration,我尝试过stackoverflow这里写的解决方案,但没有一个解决了我的问题,可能对我来说有所不同 我有两个模块,“电子邮件服务”(jar)和“电子邮件服务web”(war)包装模块。我使用maven,“电子邮件服务web”导入“电子邮件服务”jar文件。这正如预期的那样有效 “电子邮件服务web”web-INF文件夹中的My web.xml如下所示: <servlet> <servlet-name>springServlet</servlet-name&g

我尝试过stackoverflow这里写的解决方案,但没有一个解决了我的问题,可能对我来说有所不同

我有两个模块,“电子邮件服务”(jar)和“电子邮件服务web”(war)包装模块。我使用maven,“电子邮件服务web”导入“电子邮件服务”jar文件。这正如预期的那样有效

“电子邮件服务web”web-INF文件夹中的My web.xml如下所示:

<servlet>
    <servlet-name>springServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath*:/META-INF/spring/web-application-config.xml
        </param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>springServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
<import resource="classpath*:applicationContext-email-service-bootstrap.xml"/>
<import resource="classpath*:applicationContext-email-service-environment.xml"/>
<import resource="classpath*:applicationContext-email-service-process.xml"/>
<import resource="classpath*:applicationContext-email-service-integration.xml"/>

<context:component-scan base-package="com.company.emailservice"/>

因此,正如M.Deinum提到的,
WEB-INF
文件夹不在类路径中,这最终是我的问题

由于HTTP集成端点(HTTP入站通道适配器)在最初的几次尝试中没有正确响应,所以花了一段时间才弄清楚,但第3和第4个请求确实按预期响应


web应用程序config.xml
放入参考资料文件夹确实解决了问题。

web-INF不是类路径。请共享
war
结构。看起来您的
lib
dir在类路径之外:
[email-service]
`--src
   `--main
      `--src
         |--java (classes)
         `--resources
            |--applicationContext-email-service-bootstrap.xml
            |--applicationContext-email-service-environment.xml
            |--applicationContext-email-service-process.xml
            `--applicationContext-email-service-integration.xml

[email-service-web]
`--src
   `--main
      |--src
      |  `--resources
      |     `--META-INF
      |        `--spring
      |           `--web-application-config.xml
      `--webapp
         `--WEB-INF
            `--web.xml