<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>ihorder-webapp</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/applicationContext.xml
</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>production</param-value>
</context-param>
<listener>
如果被web.xml配置加载还配置spring加载会报错:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
找不到元素。。的声明
http://outofmemory.cn/java/spring/spring-DI-with-annotation-context-component-scan
<context标签和写注解缺一不可,配置里写过<bean就不要再写注解了以防冲突
<context:annotation-config/>开启注解注入
<context:component-scan base-package="com.jd.ihhotel.man.webapp" />配置spring扫描的范围,扫描不到的使用<import导入即可。