标签:source dao abs 普通java类 abstract resource 注解 bat java
使用ssm项目,很多service,dao等都使用了注解方式定义,普通java类要获取到这些bean,可这么写:
public class Common { private UserService userService; public Common() { @SuppressWarnings("resource") AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(new String []{"classpath:spring-mvc.xml","classpath:spring-mybatis.xml"}); userService = (UserService) ctx.getBean("userService"); } }
标签:source dao abs 普通java类 abstract resource 注解 bat java
原文地址:http://www.cnblogs.com/seri17/p/7098231.html