管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-27 925f925c2073d7ef0c827c1e9b97d3c008c8ff0e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.lf.server.helper;
 
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
 
/**
 * 类帮助类
 * @author WWW
 */
public class ClassHelper {
    private final static Log log = LogFactory.getLog(ClassHelper.class);
 
    /**
     * 根据类名创建实例
     *
     * @param className 类名
     * @return 实体
     */
    public static Object createInstance(String className) {
        try {
            Class clazz = Class.forName(className);
            Object obj = clazz.newInstance();
 
            return obj;
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return null;
        }
    }
 
    /**
     * 获取Bean
     *
     * @param className 类名
     * @return Bean
     */
    public static Object getBean(String className) {
        try {
            Object obj = SpringContextHelper.getBean(className);
 
            return obj;
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return null;
        }
    }
}