1、配置核心文件
(1)途径1配置web.xml文件
配置src/main/webapp/WEB-INF/下的web.xml
<!-- 加载spring容器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
(2)途径2使用测试文件
通过两个注解来构建核心容器,扫描到xml文件
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:spring/applicationContext-jms-producer.xml")
public class TestQueue {
@Autowired
private QueueProducer queueProducer;
@Test
public void sendText() {
queueProducer.sendTextMessage("springJms_queue!");
}
}
2、配置spring容器(spring文件夹下的文件)
在src/main/resources/spring文件夹下建立配置文件,如:
applicationContext-service.xml、applicationContext-tx.xml等
所有的对象都在这个spring容器之中