spring boot 添加自定义属性
1.添加jar
compile('org.springframework.boot:spring-boot-configuration-processor:1.2.0.RELEASE')
2.在application.properties中设置自定义属性
#------微信App支付参数------
#终端设备号(门店号或收银设备ID),默认请传"WEB"
weixinpay.device_info=WEB
#符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
weixinpay.fee_type=CNY
#微信开放平台审核通过的应用APPID
weixinpay.appid=*******
#微信支付分配的商户号
weixinpay.mch_id=********
#接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
weixinpay.notify_url=***********
3.自定义对象
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component @ConfigurationProperties(prefix = "weixinpay")
@Component
class WeiXinPayConfig { var device_info: String? = null
var fee_type: String? = null
var appid: String? = null
var mch_id: String? = null
var notify_url: String? = null override fun toString(): String {
return "WeiXinPayConfig(device_info=$device_info, fee_type=$fee_type, appid=$appid, mch_id=$mch_id, notify_url=$notify_url)"
} }
4.可直接使用
import com.lanhetech.paymodule.config.WeiXinPayConfig
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController @RestController
class PayModuleController { val logger = LoggerFactory.getLogger(this.javaClass) @Autowired
var weiXinPayConfig: WeiXinPayConfig? = null @GetMapping("/payByWeiXin")
fun payByWeiXin() { logger.info(weiXinPayConfig.toString()) } }
spring boot 添加自定义属性的更多相关文章
- Spring Boot 添加JSP支持【转】
Spring Boot 添加JSP支持 大体步骤: (1) 创建Maven web project: (2) 在pom.xml文件添加依赖: (3) ...
- 19. Spring Boot 添加JSP支持【从零开始学Spring Boot】
转:http://blog.csdn.net/linxingliang/article/details/52017140 这个部分比较复杂,所以单独创建一个工程来进行讲解: 大体步骤: (1) ...
- (19)Spring Boot 添加JSP支持【从零开始学Spring Boot】
[来也匆匆,去也匆匆,在此留下您的脚印吧,转发点赞评论: 您的认可是我最大的动力,感谢您的支持] 看完本文章您可能会有些疑问,可以查看之后的一篇博客: 81. Spring Boot集成JSP疑问[从 ...
- 超简单,spring boot 添加mybatis
看了很多人写的博客,要么太复杂,要么没有添加xml的方式,自己亲自配置了一下,供各位参考. 项目截图 1.添加pom文件 <!-- 设置mybatis --> <dependency ...
- spring boot 添加拦截器
构建一个spring boot项目. 添加拦截器需要添加一个configuration @Configuration @ComponentScan(basePackageClasses = Appli ...
- Spring Boot 添加Shiro支持
前言: Shiro是一个权限.会话管理的开源Java安全框架:Spring Boot集成Shiro后可以方便的使用Session: 工程概述: (工程结构图) 一.建立Spring Boot工程 参照 ...
- Spring Boot 添加jersey-mvc-freemarker依赖后内置tomcat启动不了解决方案
我在我的Spring Boot 项目的pom.xml中添加了jersey-mvc-freemarker依赖后,内置tomcat启动不了. 报错信息如下: org.springframework.con ...
- spring boot 添加拦截器的简单实例(springBoot 2.x版本,添加拦截器,静态资源不可访问解决方法)
spring中拦截器主要分两种,一个是HandlerInterceptor,一个是MethodInterceptor 一.HandlerInterceptor HandlerInterceptor是s ...
- 2018-08-16 中文代码之Spring Boot添加基本日志
之前中文代码之Spring Boot实现简单REST服务的演示服务不知为何中止. 新开issue: 演示服务中止 · Issue #2 · program-in-chinese/programming ...
随机推荐
- Python3 生成器
生成器(genetor): 1>生成器只有在调用的时候才会生成相应的数据: 2>生成器只记录当前位置,有一个__next__()方法 3>yield可以实现单线程先的并发运算 1.列 ...
- 分布式队列Celery
Celery是什么? Celery 是一个由 Python 编写的简单.灵活.可靠的用来处理大量信息的分布式系统,它同时提供操作和维护分布式系统所需的工具. Celery 专注于实时任务处理,支持任务 ...
- kimbits_USACO
StringsobitsKim Schrijvers Consider an ordered set S of strings of N (1 <= N <= 31) bits. Bits ...
- linux 自旋锁和信号量【转】
转自:http://blog.csdn.net/xu_guo/article/details/6072823 版权声明:本文为博主原创文章,未经博主允许不得转载. 自旋锁最多只能被一个可执行线程持有( ...
- rhel-server srpms iso
http://ftp.redhat.com/pub/redhat/linux/enterprise/7Server/en/ ftp://ftp.pslib.cz/pub/linux/redhat-cz ...
- 异步网络模块之aiohttp的使用(一)
异步网络模块之aiohttp的使用(一) 平时我们也许用的更多的是requests模块,或者是requests_hml模块,但是他们都属于阻塞类型的不支持异步,速度很难提高,于是后来出现了异步的gre ...
- c basic library framework - simplec 2.0.0
前言 - simplec 单元测试 流程介绍 一个关于C基础库 simplec 2.0.0 发布了. 详细的文档介绍请参照 README.md. 说的再多都无用, 抵不上 gdb 一个 b r n. ...
- docker基于本地模版导入创建镜像
/* 因为直接去网站拿会下载的慢,所以直接到网站里,对着此包--〉右键--〉复制链接地址 网站地址:https://openvz.org/Download/template/precreated */ ...
- App推广
一行业常见名词解释 开发商:也叫CP,即Content Provider内容提供商的英文首字母缩写. 发行商(运营商):即代理CP开发出来的产品. 渠道:拥有用户,能够进行流量分发的公司,即可成为渠道 ...
- 80端口被System进程占用问题
更新: 有可能占用80端口的服务: 如果安装了IIS,关闭IIS: 如果未开启IIS功能,而安装了诸如Web Matrix的开发程序,则有可能被Web Development Agent Servic ...