⒈编写自定义配置类

  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. ZooKeeper集群详细安装教程

    1. 安装JDK 1.1 官网下载JDK 进入网址<a href="http://www.oracle.com/technetwork/java/javase/downloads/jd ...

  2. [报错]Could not get a resource from the pool

    redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool解决:开启 ...

  3. AtomicInteger类的理解与使用

    AtomicInteger类的理解与使用 首先看两段代码,一段是Integer的,一段是AtomicInteger的,为以下: public class Sample1 { private stati ...

  4. 6-(基础入门篇)学会编译lua固件,固件的合成

    http://www.cnblogs.com/yangfengwu/p/9336274.html 基础教程源码链接请在淘宝介绍中下载,由于链接很容易失效,如果失效请联系卖家,谢谢 https://it ...

  5. 使用JMeter进行一次简单的带json数据的post请求测试,json可配置参数

    配置: 1.新建一个线程组: 然后设置线程数.运行时间.重复次数. 2.新建Http请求: 设置服务器域名,路径,方法,编码格式,数据内容. 可以在函数助手中,编辑所需要的变量,比如本例中的随机生成电 ...

  6. Linux 下装逼技巧

    ``` 1.下载cmatrix-1.2a.tar.gz文件 [root@localhost ~]# wget https://jaist.dl.sourceforge.net/project/cmat ...

  7. 解析ArcGis拓扑——检查的流程,以面重叠检查为例

    最简单的面重叠错误检查是使用“地理处理”——“面相交”进行检查,其结果是重叠部分提取而成的新面要素类.本例不讲述此种方法. step1 准备待拓扑检查数据 名词: 数据库 DataBase→顾名思义, ...

  8. 905. Sort Array By Parity

    Description Given an array A of non-negative integers, return an array consisting of all the even el ...

  9. instanceof 操作符实现原理解析

    本文会介绍ES6规范中 instanceof 操作符的实现,以及自定义 instanceof 操作符行为的几个方法. 文中涉及的规范相关的代码皆为伪代码,为了便于理解,其中可能会省略一些参数判断逻辑或 ...

  10. Burpsuite之Burp Collaborator模块介绍

    Burp Collaborator.是从Burp suite v1.6.15版本添加的新功能,它几乎是一种全新的渗透测试方法.Burp Collaborator.会渐渐支持blind XSS,SSRF ...