zoukankan      html  css  js  c++  java
  • spring boot 读取配置文件yml

    @Component
    @ConfigurationProperties(prefix = "api")
    @PropertySource(value = { "classpath:api.yml" })


    package com.foen.api.config;
    
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.boot.context.properties.ConfigurationProperties;
    import org.springframework.context.annotation.PropertySource;
    import org.springframework.stereotype.Component;
    
    /**
     * 读取代码生成相关配置
     *  get static,
     *  set @Value(“${}”)
     * 
     * @author foen
     */
    @Component
    @ConfigurationProperties(prefix = "api")
    @PropertySource(value = { "classpath:api.yml" })
    public class ApiConfig
    {
        /** 作者 */
        public static String author;
    
        /** 生成包路径 */
        public static String packageName;
    
        /** 自动去除表前缀,默认是false */
        public static boolean autoRemovePre;
    
        /** 表前缀(类名不会包含表前缀) */
        public static String tablePrefix;
        /** 表前缀(类名不会包含表前缀) */
        public static String testUrl;
        /** 表前缀(类名不会包含表前缀) */
        public static String proUrl;
    
        public static String getAuthor()
        {
            return author;
        }
    
        @Value("${author}")
        public void setAuthor(String author)
        {
            ApiConfig.author = author;
        }
    
        public static String getPackageName()
        {
            return packageName;
        }
    
        @Value("${packageName}")
        public void setPackageName(String packageName)
        {
            ApiConfig.packageName = packageName;
        }
    
        public static boolean getAutoRemovePre()
        {
            return autoRemovePre;
        }
    
        @Value("${autoRemovePre}")
        public void setAutoRemovePre(boolean autoRemovePre)
        {
            ApiConfig.autoRemovePre = autoRemovePre;
        }
    
        public static String getTablePrefix()
        {
            return tablePrefix;
        }
    
        @Value("${tablePrefix}")
        public void setTablePrefix(String tablePrefix)
        {
            ApiConfig.tablePrefix = tablePrefix;
        }
    
        public static String getTestUrl() {
            return testUrl;
        }
        @Value("${testUrl}")
        public void setTestUrl(String testUrl) {
            ApiConfig.testUrl = testUrl;
        }
    
        public static String getProUrl() {
            return proUrl;
        }
        @Value("${proUrl}")
        public void setProUrl(String proUrl) {
            ApiConfig.proUrl = proUrl;
        }
    }
    

      

  • 相关阅读:
    【水滴石穿】RNNewsGo
    【水滴石穿】FirstReactNativeProject
    EF4.0和EF5.0增删改查的写法区别及执行Sql的方法
    SQL 2005中char、nchar、varchar、ntext and nvarchar(max)的区别
    七秘诀工作效率与薪水翻番-转
    NopCommerce架构分析(转载)
    转:一个基于互联网医疗的创业公司,三年是一个收获
    如何学习开源系统有感(一)
    C#的CLR组成和运转介绍
    jquery 选择器,模糊匹配
  • 原文地址:https://www.cnblogs.com/gzhbk/p/14086195.html
Copyright © 2011-2022 走看看