⒈编写自定义配置类

  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. ajax传值修改数据

    主界面代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. ...

  2. C# 封装SqlBulkCopy,让批量插入更方便

    关于 SqlServer 批量插入的方式,前段时间也有大神给出了好几种批量插入的方式及对比测试(http://www.cnblogs.com/jiekzou/p/6145550.html),估计大家也 ...

  3. Go strings.Builder

    Go strings.Builder 字符串拼接操作优化 最开始的时候,可能会使用如下的操作: package main func main() { ss := []string{ "sh& ...

  4. SQL语法基础之CREATE语句

    SQL语法基础之CREATE语句 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.查看帮助信息 1>.使用“?”来查看MySQL命令的帮助信息 mysql> ? CR ...

  5. 鼠标右键Table的td弹出多级菜单,双击td编辑

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C ...

  6. UESTC - 1999 也许这是唯一能阻止乐爷AK的方法( Just for Fun )(回文树)

    https://vjudge.net/problem/UESTC-1999 题意 对于一个初始为空的字符串S,你可以进行以下两种操作: 1. 在S的末尾加一个小写字母. 2. 移除S的最后一个字母. ...

  7. 让Windows Server 2008r2 IIS7.5 ASP.NET 支持10万并发请求

    由于之前使用的是默认配置,服务器最多只能处理5000个同时请求,今天下午由于某种情况造成同时请求超过5000,从而出现了上面的错误. 为了避免这样的错误,我们根据相关文档调整了设置,让服务器从设置上支 ...

  8. authenticate验证的流程

    from django.contrib.auth import authenticate # 默认的第一个加密算法 class PBKDF2PasswordHasher(BasePasswordHas ...

  9. 在java1.8下使用jetty报错java.lang.CharSequence cannot be resolved

    环境: JDK: 1.8Jetty: jetty6,jetty7(在eclipse中使用run-jetty-run插件) 在JSP页面中使用StringBuilder或者StringBuffer,示例 ...

  10. vim学习之改头换面(基础配置)

    还记得在线有个维护博客园的学长说过,这网站的前端做的贼丑,今日一看果真如此.其实我想说毕竟干货多,没有那么多花花肠子.下面开始进入正题. 在入坑了sublime.vscode.atom.notepad ...