WangHan
2024-09-12 d5855a4926926698b740bc6c7ba489de47adb68b
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package tech.powerjob.server.persistence.config;
 
import com.google.common.collect.Maps;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
 
import java.util.*;
 
/**
 * 多重数据源配置
 *
 * @author Kung Yao
 * @since 2020/4/27
 */
@Component
@ConfigurationProperties("spring.datasource")
public class MultiDatasourceProperties {
 
    private DataSourceProperties remote = new DataSourceProperties();
 
    private DataSourceProperties local = new DataSourceProperties();
 
 
    public static class DataSourceProperties {
 
        private HibernateProperties hibernate = new HibernateProperties();
 
        public void setHibernate(HibernateProperties hibernate) {
            this.hibernate = hibernate;
        }
 
        public HibernateProperties getHibernate() {
            return hibernate;
        }
    }
 
 
    public static class HibernateProperties {
 
        private Map<String, String> properties = Maps.newHashMap();
 
        public void setProperties(Map<String, String> properties) {
            this.properties = properties;
        }
 
        public Map<String, String> getProperties() {
            return properties;
        }
    }
 
    public void setLocal(DataSourceProperties local) {
        this.local = local;
    }
 
    public void setRemote(DataSourceProperties remote) {
        this.remote = remote;
    }
 
    public DataSourceProperties getLocal() {
        return local;
    }
 
    public DataSourceProperties getRemote() {
        return remote;
    }
}