SpringBoot编写自定义配置信息
⒈编写自定义配置类
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编写自定义配置信息的更多相关文章
- ASP.NET MVC 学习笔记-7.自定义配置信息(后续)
自定义配置信息的高级应用 通过上篇博文对简单的自定义配置信息的学习,使得更加灵活的控制系统配置信息.实际项目中,这种配置的灵活度往往无法满足项目的灵活度和扩展性. 比如,一个配置信息有三部分组成,而每 ...
- ASP.NET MVC 学习笔记-7.自定义配置信息
ASP.NET程序中的web.config文件中,在appSettings这个配置节中能够保存一些配置,比如, <appSettings> <add key="LogInf ...
- 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 ...
- springboot 入门八-自定义配置信息(编码、拦截器、静态资源等)
若想实际自定义相关配置,只需要继承WebMvcConfigurerAdapter.WebMvcConfigurerAdapter定义些空方法用来重写项目需要用到的WebMvcConfigure实现.具 ...
- springboot自定义配置信息读取
在properties配置文件加入自定义配置例如: zxgl.detail.url=http://*****/zxgl-web/news/viewNewsIndexDetail.do?id= #资讯t ...
- SpringBoot编写自定义的starter 专题
What’s in a name All official starters follow a similar naming pattern; spring-boot-starter-*, where ...
- Springboot之自定义配置
SpringBoot自定义配置 springboot在这里就不过多介绍了,大家都应该了解springboot零配置文件,所以配置信息都装配在属性文件(properties.yml.yaml)中,有时我 ...
- springboot 02-PropertiesFile 自定义配置属性,多环境配置
application.properties: # 自定义配置 test.hello.world = HelloWorld test.person.name = 哈哈 test.person.sex ...
- SpringBoot编写自定义Starter
根据SpringBoot的Starter编写规则,需要编写xxxStarter依赖xxxAutoConfigurer,xxxStarter是一个空的jar,仅提供辅助性的依赖管理,引入其他类库 1.建 ...
随机推荐
- [DUBBO] Unexpected error occur at send statistic, cause: Forbid consumer 192.168.3.151 access servic
[DUBBO] Unexpected error occur at send statistic, cause: Forbid consumer 192.168.3.151 access servic ...
- varStatus="vs"
通过在百度上查看,发现是属于JSTL 标签.我具体说一下用途吧 就是删除/新增的时候,序号总是连续的从1开始排列,序号的数据与数据库没有关系,序号并不等于id,在数据库中的id仍然是原来的那样,不连续 ...
- java io系列19之 CharArrayWriter(字符数组输出流)
本章,我们学习CharArrayWriter.学习时,我们先对CharArrayWriter有个大致了解,然后深入了解一下它的源码,最后通过示例来掌握它的用法. 转载请注明出处:http://www. ...
- Web API中的路由(二)——属性路由
一.属性路由的概念 路由让webapi将一个uri匹配到对应的action,Web API 2支持一种新类型的路由:属性路由.顾名思义,属性路由使用属性来定义路由.通过属性路由,我们可以更好地控制We ...
- HDU - 4625 JZPTREE(第二类斯特林数+树DP)
https://vjudge.net/problem/HDU-4625 题意 给出一颗树,边权为1,对于每个结点u,求sigma(dist(u,v)^k). 分析 贴个官方题解 n^k并不好转移,于是 ...
- 历史SQL语句之一
注释:查询该课程表下,所有的课程以及课程观看的人数统计 SELECT ml.`name` as lessonName,ml.category,ml.deleted,ml.teacherName, ml ...
- SpringBoot系列: logging
我们的 SpringBoot 程序都会加 spring-boot-starter 包, 而该包一个依赖项 spring-boot-starter-logging, 所以SpringBoot 程序不需要 ...
- 使用二分查找判断某个数在某个区间中--如何判断某个IP地址所属的地区
一,问题描述 给定100万个区间对,假设这些区间对是互不重叠的,如何判断某个数属于哪个区间? 首先需要对区间的特性进行分析:区间是不是有序的?有序是指:后一个区间的起始位置要大于前一个区间的终点位置. ...
- js call使用
call 方法 请参阅 应用于:Function 对象 要求 版本 5.5 调用一个对象的一个方法,以另一个对象替换当前对象. call([thisObj[,arg1[, arg2[, [,.argN ...
- Docker 更改默认存储目录 - 十一
Cemtos 7 Docker 默认目录是 /var/lib/docker docker info 查看 docker 配置信息 更改 docker 默认目录 : 编辑 启动文件: 编辑 /usr/ ...