项目使用的是SSM体系,spring的配置如下,配置没问题,因为我发现其他文件中的@Value可以使用,只有一处@Value失效了。
spring-servlet.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xmlns:mvc="http://www.springframework.org/schema/mvc" 5 xmlns:context="http://www.springframework.org/schema/context" 6 xmlns:aop="http://www.springframework.org/schema/aop" 7 xmlns:tx="http://www.springframework.org/schema/tx" 8 xmlns:websocket="http://www.springframework.org/schema/websocket" 9 xsi:schemaLocation="http://www.springframework.org/schema/beans 10 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 11 http://www.springframework.org/schema/mvc 12 http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd 13 http://www.springframework.org/schema/context 14 http://www.springframework.org/schema/context/spring-context-4.0.xsd 15 http://www.springframework.org/schema/aop 16 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 17 http://www.springframework.org/schema/tx 18 http://www.springframework.org/schema/tx/spring-tx-4.0.xsd 19 http://www.springframework.org/schema/websocket 20 http://www.springframework.org/schema/websocket/spring-websocket.xsd"> 21 22 <context:property-placeholder ignore-unresolvable="true" location="classpath*:config.properties" /> 23 24 25 <!-- 使用Annotation自动注册Bean,Controllerller --> 26 <context:component-scan base-package="com.magicmed.ecg" use-default-filters="false"> <!--base-package 如果多个,用“,”分隔--> 27 <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> 28 </context:component-scan> 29 30 <!-- 自定义注解实现日志记录 --> 31 <aop:aspectj-autoproxy /> 32 33 <mvc:annotation-driven /> 34 35 36 <import resource="classpath:mybatis-spring.xml" /> 37 <import resource="classpath:mail-spring.xml" /> 38 <import resource="classpath:rabbitmq-spring.xml" /> 39 40 </beans>