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 添加自定义属性的更多相关文章

  1. Spring Boot 添加JSP支持【转】

    Spring Boot 添加JSP支持 大体步骤: (1)            创建Maven web project: (2)            在pom.xml文件添加依赖: (3)     ...

  2. 19. Spring Boot 添加JSP支持【从零开始学Spring Boot】

    转:http://blog.csdn.net/linxingliang/article/details/52017140 这个部分比较复杂,所以单独创建一个工程来进行讲解: 大体步骤: (1)     ...

  3. (19)Spring Boot 添加JSP支持【从零开始学Spring Boot】

    [来也匆匆,去也匆匆,在此留下您的脚印吧,转发点赞评论: 您的认可是我最大的动力,感谢您的支持] 看完本文章您可能会有些疑问,可以查看之后的一篇博客: 81. Spring Boot集成JSP疑问[从 ...

  4. 超简单,spring boot 添加mybatis

    看了很多人写的博客,要么太复杂,要么没有添加xml的方式,自己亲自配置了一下,供各位参考. 项目截图 1.添加pom文件 <!-- 设置mybatis --> <dependency ...

  5. spring boot 添加拦截器

    构建一个spring boot项目. 添加拦截器需要添加一个configuration @Configuration @ComponentScan(basePackageClasses = Appli ...

  6. Spring Boot 添加Shiro支持

    前言: Shiro是一个权限.会话管理的开源Java安全框架:Spring Boot集成Shiro后可以方便的使用Session: 工程概述: (工程结构图) 一.建立Spring Boot工程 参照 ...

  7. Spring Boot 添加jersey-mvc-freemarker依赖后内置tomcat启动不了解决方案

    我在我的Spring Boot 项目的pom.xml中添加了jersey-mvc-freemarker依赖后,内置tomcat启动不了. 报错信息如下: org.springframework.con ...

  8. spring boot 添加拦截器的简单实例(springBoot 2.x版本,添加拦截器,静态资源不可访问解决方法)

    spring中拦截器主要分两种,一个是HandlerInterceptor,一个是MethodInterceptor 一.HandlerInterceptor HandlerInterceptor是s ...

  9. 2018-08-16 中文代码之Spring Boot添加基本日志

    之前中文代码之Spring Boot实现简单REST服务的演示服务不知为何中止. 新开issue: 演示服务中止 · Issue #2 · program-in-chinese/programming ...

随机推荐

  1. ES6 新增的一些东西

    一.常量 不允许重复定义 const a='HELLO' const a='world'//报错Uncaught SyntaxError: Identifier 'a' has already bee ...

  2. 为什么IO多路复用需要采用非阻塞式IO

    近段时间开始学习<Unix网络编程>,代码实现了一个简单的IO多路复用+阻塞式的服务端,在学习了非阻塞式IO后,有一个疑问,即: 假如调用了select,并且关注了几个描述字,当关注的描述 ...

  3. Keil MDK 5.14 仿真时System Viewer菜单显示空白和Peripherals菜单无外设寄存器

    keil mdk5.14新建工程进行仿真时,进入Debug环境发现System Viewer菜单显示空白,Peripherals菜单没有外设寄存器.如图1和图2所示.打开Oprons for Targ ...

  4. 仿照linux dpm机制,实现自己的dpm【转】

    转自:http://blog.csdn.net/lixiaojie1012/article/details/23788713 前边我们讨论分析了linux 内核的dpm实现,分析的目的在于学以致用:在 ...

  5. hardseed

    hardseed https://github.com/yangyangwithgnu/hardseed

  6. django wsgi nginx 配置

    """ WSGI config for HelloWorld project. It exposes the WSGI callable as a module-leve ...

  7. SPOJ 375

    默默一看提交时间 -- 这是我以前的代码风格-- #include <cstdio> #include <cstring> #include <vector> #i ...

  8. mac date命令

    usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... [-f fmt date | [[[mm]dd ...

  9. Solr产品化部署

    1.下载solr-6.4.1.tgz到任意目录 2.执行tar xzf solr-6.4.1.tgz solr-6.4.1/bin/install_solr_service.sh --strip-co ...

  10. LeetCode解题报告—— Word Search & Subsets II & Decode Ways

    1. Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be con ...