@RunWith(SpringRunner.class)
//@SpringBootTest(classes = PersonConfig.class)
@ContextConfiguration(classes = PersonConfig.class)
public class Test {
@Resource
private PersonEventService personEventService;
@Test
public void test() {
// ApplicationContext context = new AnnotationConfigApplicationContext(PersonEventService.class);
// PersonEventService personEventService = context.getBean(PersonEventService.class);
System.out.println(personEventService);
personEventService.registerUser("userName222");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/s ... ing-context-3.1.xsd >
<!-- 自动扫描该包 -->
<context:component-scan base-package="com" />
</beans>
/**
* 配置文件java
*/
@Configuration
@ComponentScan("com.xxx.xxx.controller.eventtest")
public class PersonEventConfig {
}
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |