多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
**1.注解配置类** ~~~ package com.nobb; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; //声明是spring容器的配置类 @Configuration //扫描基础包及子包 @ComponentScan("com.nobb") //开启自动扫描aop注解 @EnableAspectJAutoProxy public class ApplicationContextConfiguration { } ~~~ **2.测试代码** ~~~ import com.nobb.ApplicationContextConfiguration; import com.nobb.service.UserService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.annotation.Resource; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = ApplicationContextConfiguration.class) public class AopTest1 { @Resource(name="userService") private UserService userService; @Test public void fun1(){ userService.save(); } } ~~~