| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | import org.springframework.context.ApplicationContext;
|
| | | import org.springframework.context.support.FileSystemXmlApplicationContext;
|
| | |
|
| | | public class BeanUtil {
|
| | |
|
| | | private static ApplicationContext applicationContext = null;
|
| | |
|
| | | public static ApplicationContext getApplicationContext() {
|
| | | if (applicationContext == null)
|
| | | applicationContext = new FileSystemXmlApplicationContext("classpath:spring.xml");
|
| | | return applicationContext;
|
| | | }
|
| | |
|
| | | public static Object getBean(String id) {
|
| | |
|
| | | return getApplicationContext().getBean(id);
|
| | | }
|
| | |
|
| | | public static <T> T getBean(Class<T> requiredType) {
|
| | | return getApplicationContext().getBean(requiredType);
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.util; |
| | | |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.support.FileSystemXmlApplicationContext; |
| | | |
| | | public class BeanUtil { |
| | | |
| | | private static ApplicationContext applicationContext = null; |
| | | |
| | | public static ApplicationContext getApplicationContext() { |
| | | if (applicationContext == null) |
| | | applicationContext = new FileSystemXmlApplicationContext("classpath:spring.xml"); |
| | | return applicationContext; |
| | | } |
| | | |
| | | public static Object getBean(String id) { |
| | | |
| | | return getApplicationContext().getBean(id); |
| | | } |
| | | |
| | | public static <T> T getBean(Class<T> requiredType) { |
| | | return getApplicationContext().getBean(requiredType); |
| | | } |
| | | |
| | | } |