mirror of
https://github.com/JeffLi1993/springboot-learning-example.git
synced 2026-03-14 22:23:54 +08:00
Spring Boot 之配置注解使用
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package org.spring.springboot.config;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Spring Boot MessageConfiguration 测试 - {@link MessageConfiguration}
|
||||
*
|
||||
*/
|
||||
public class MessageConfigurationTest {
|
||||
|
||||
@Test
|
||||
public void testGetMessageBean() throws Exception {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MessageConfiguration.class);
|
||||
assertEquals("message configuration", ctx.getBean("message"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScanPackages() throws Exception {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.scan("org.spring.springboot");
|
||||
ctx.refresh();
|
||||
assertEquals("message configuration", ctx.getBean("message"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user