⒈编写自定义配置类

  1.浏览器配置

 package cn.coreqi.security.properties;

 public class BrowserProperties {

     private String loginPage = "coreqi-signIn.html";   //登录页面

     private LoginType loginType = LoginType.JSON;

     public LoginType getLoginType() {
return loginType;
} public void setLoginType(LoginType loginType) {
this.loginType = loginType;
} public String getLoginPage() {
return loginPage;
} public void setLoginPage(String loginPage) {
this.loginPage = loginPage;
}
}

  2.安全配置中包含了浏览器配置

 package cn.coreqi.security.properties;

 import org.springframework.boot.context.properties.ConfigurationProperties;

 @ConfigurationProperties(prefix = "coreqi.security")
public class SecurityProperties {
private BrowserProperties browser = new BrowserProperties(); public BrowserProperties getBrowser() {
return browser;
} public void setBrowser(BrowserProperties browser) {
this.browser = browser;
}
}

⒉在配置文件中配置

 coreqi.security.browser.loginPage=/coreqi-signIn.html

⒊开启自定义配置,并在代码中引用

 package cn.coreqi.security.config;

 import cn.coreqi.security.properties.SecurityProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration; @Configuration
@EnableConfigurationProperties(value = {SecurityProperties.class})
public class SecurityPropertiesConfig {
@Autowired
private SecurityProperties securityProperties;
public void test(){
System.out.println(securityProperties.getBrowser().getLoginPage());
}
}

SpringBoot编写自定义配置信息的更多相关文章

  1. ASP.NET MVC 学习笔记-7.自定义配置信息(后续)

    自定义配置信息的高级应用 通过上篇博文对简单的自定义配置信息的学习,使得更加灵活的控制系统配置信息.实际项目中,这种配置的灵活度往往无法满足项目的灵活度和扩展性. 比如,一个配置信息有三部分组成,而每 ...

  2. ASP.NET MVC 学习笔记-7.自定义配置信息

    ASP.NET程序中的web.config文件中,在appSettings这个配置节中能够保存一些配置,比如, <appSettings> <add key="LogInf ...

  3. ASP.NET MVC 学习笔记-7.自定义配置信息 ASP.NET MVC 学习笔记-6.异步控制器 ASP.NET MVC 学习笔记-5.Controller与View的数据传递 ASP.NET MVC 学习笔记-4.ASP.NET MVC中Ajax的应用 ASP.NET MVC 学习笔记-3.面向对象设计原则

    ASP.NET MVC 学习笔记-7.自定义配置信息   ASP.NET程序中的web.config文件中,在appSettings这个配置节中能够保存一些配置,比如, 1 <appSettin ...

  4. springboot 入门八-自定义配置信息(编码、拦截器、静态资源等)

    若想实际自定义相关配置,只需要继承WebMvcConfigurerAdapter.WebMvcConfigurerAdapter定义些空方法用来重写项目需要用到的WebMvcConfigure实现.具 ...

  5. springboot自定义配置信息读取

    在properties配置文件加入自定义配置例如: zxgl.detail.url=http://*****/zxgl-web/news/viewNewsIndexDetail.do?id= #资讯t ...

  6. SpringBoot编写自定义的starter 专题

    What’s in a name All official starters follow a similar naming pattern; spring-boot-starter-*, where ...

  7. Springboot之自定义配置

    SpringBoot自定义配置 springboot在这里就不过多介绍了,大家都应该了解springboot零配置文件,所以配置信息都装配在属性文件(properties.yml.yaml)中,有时我 ...

  8. springboot 02-PropertiesFile 自定义配置属性,多环境配置

    application.properties: # 自定义配置 test.hello.world = HelloWorld test.person.name = 哈哈 test.person.sex ...

  9. SpringBoot编写自定义Starter

    根据SpringBoot的Starter编写规则,需要编写xxxStarter依赖xxxAutoConfigurer,xxxStarter是一个空的jar,仅提供辅助性的依赖管理,引入其他类库 1.建 ...

随机推荐

  1. C# 实现身份验证之WEB Service篇

    在这个WEB API横行的时代,讲WEB Service技术却实显得有些过时了,过时的技术并不代表无用武之地,有些地方也还是可以继续用他的,我之所以会讲解WEB Service,源于我最近面试时被问到 ...

  2. JAVA-序列化深拷贝对象

    序列化拷贝方法 @SuppressWarnings("unchecked") public static <T extends Serializable> T clon ...

  3. JAVA核心技术I---JAVA基础知识(常量设计和常量池)

    一:常量---一种不会修改的变量 –Java没有constant关键字 –不能修改,final –不会修改/只读/只要一份,static –方便访问publicJava中的常量 –public sta ...

  4. linq总结系列(一)---基础部分

    一.linq的基本概念 LINQ是C#和VB中的统一查询语法,使用对象来保存和检索来自不同来源(如数据库.xml.对象集合)的数据. 主要功能:消除了编程语言和数据库之间的不匹配,以及为不同类型的数据 ...

  5. BIO和NIO

    在了解BIO,NIO,AIO之前先了解一下IO的几个概念:   1.同步与异步 同步和异步关注的是消息通信机制 (synchronous communication/ asynchronous com ...

  6. HDU - 3642 Get The Treasury(线段树求体积交)

    https://cn.vjudge.net/problem/HDU-3642 题意 求立方体相交至少3次的体积. 分析 三维的呢..首先解决至少覆盖三次的问题.则用三个标记,更新时的细节要注意. 注意 ...

  7. bzoj千题计划312:bzoj2119: 股市的预测(后缀数组+st表)

    https://www.lydsy.com/JudgeOnline/problem.php?id=2119 题意:将给定数组差分后,求ABA形式的字串个数,要求|B|=m,|A|>0 1.后缀数 ...

  8. hdu 6385

    题意是在一个矩形中任给N个点,求这N个点到矩形某边的最短距离和. 一开始想到直接贪心,求出每个点到矩形一边的最短距离,但题中说到线段间不能交叉,这里好像是比较麻烦,但题目中同时说了点与点之间的横纵坐标 ...

  9. 01-maya基础

    maya基础 1,ctrl shift m 切换面板工具栏. 2,空格键+ 右键 :快速的切换视图. 3,在一视图上单击空格键,可放大显示. 4, 工程的创建 1,创建工程:文件--项目窗口,建完后, ...

  10. Dictionary与SortedDictionary

    Dictionary是无序的,如果想排序,需要使用SortDictionary. 下面是一个用法示例 //按照某个字段排序 public void SortByCardItem(string item ...