PropertiesConfiguration.java 2.75 KB
package com.viontech.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.InputStream;
import java.util.Properties;

@Configuration
@Slf4j
public class PropertiesConfiguration {
    @Bean(name = "wflxProperties")
    public Properties wflxProperties() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/wflx.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 wflx.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "hpysProperties")
    public Properties hpysProperties() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/hpys.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 hpys.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "hpzlProperties")
    public Properties hpzlProperties() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/hpzl.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 hpzl.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "csysProperties")
    public Properties csysProperties() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/csys.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 csys.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "cllxProperties")
    public Properties cllxProperties() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/cllx.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 cllx.properties 失败", e);
        }
        return properties;
    }

    @Bean(name = "clppProperties")
    public Properties clppProperties() {
        Properties properties = new Properties();
        try (InputStream inputStream = PropertiesConfiguration.class.getResourceAsStream("/dict/clpp.properties")) {
            properties.load(inputStream);
        } catch (Exception e) {
            log.error("读取 clpp.properties 失败", e);
        }
        return properties;
    }
}