您的位置:首页 > 编程语言 > Java开发

Spring 事件机制

2015-07-05 22:24 162 查看
通过模拟邮件的发送,说明Spring的事件监听机制

事件类

package org.zln.module_chapter2.event;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import static org.junit.Assert.*;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"/org/zln/cfg/spring/applicationContext.xml"})/*启动Spring容器*/
public class MailSenderTest {

@Autowired
@Qualifier("mailSender")
private MailSender mailSender;

@Test
public void testSetApplicationContext() throws Exception {

}

@Test
public void testSendMail() throws Exception {
mailSender.sendMail("nbzlnzlq@126.com");
}
}


D:\GitHub\tools\JavaEEDevelop\Lesson17_JavaWebDemo\test\org\zln\module_chapter2\event\MailSenderTest.java
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: