标签:imp util path serial org 相关 put zab rop
pay.properties
# 微信支付的appid
wxpay.appid=w23232323
# 支付密钥
wxpay.sercret=abd
# 微信支付商户号
wx.mechid=1234
TestController.java
package net.cyb.demo.controller; import net.cyb.demo.utils.JsonData; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.Map; @RestController @RequestMapping("/api/v1/test") @PropertySource({"classpath:pay.properties"}) public class TestController { @Value("wxpay.appid") private String payAppid; @Value("wxpay.sercret") private String paySecret; @GetMapping("get_config") public JsonData testConfig(){ Map<String,String> map=new HashMap<>(); map.put("appid",payAppid); map.put("secret",paySecret); return JsonData.buildSuccess(map); } }
pay.properties
# 微信支付的appid
wxpay.appid=w23232323
# 支付密钥
wxpay.sercret=abd
# 微信支付商户号
wx.mechid=1234
WXConfig.java
package net.cyb.demo.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import java.io.Serializable; @Configuration @PropertySource({"classpath:pay.properties"}) public class WXConfig implements Serializable { @Value("wxpay.appid") private String payAppid; @Value("wxpay.sercret") private String paySecret; @Value("wx.mechid") private String payMechId; public String getPayAppid() { return payAppid; } public void setPayAppid(String payAppid) { this.payAppid = payAppid; } public String getPaySecret() { return paySecret; } public void setPaySecret(String paySecret) { this.paySecret = paySecret; } public String getPayMechId() { return payMechId; } public void setPayMechId(String payMechId) { this.payMechId = payMechId; } }
TestController.java
package net.cyb.demo.controller; import net.cyb.demo.config.WXConfig; import net.cyb.demo.utils.JsonData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.Map; @RestController @RequestMapping("/api/v1/test") public class TestController { @Autowired private WXConfig wxConfig; @GetMapping("get_config") public JsonData testConfig(){ Map<String,String> map=new HashMap<>(); map.put("appid",wxConfig.getPayAppid()); map.put("secret",wxConfig.getPaySecret()); map.put("mechid",wxConfig.getPayMechId()); return JsonData.buildSuccess(map); } }
标签:imp util path serial org 相关 put zab rop
原文地址:https://www.cnblogs.com/chenyanbin/p/13236903.html