1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

add spring enviroment extension module for examples

This commit is contained in:
得少
2019-01-09 23:02:04 +08:00
parent ee2c696bdf
commit a4f8cc7d28
9 changed files with 133 additions and 8 deletions

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.cloud.alibaba.cloud.example;
import org.springframework.alicloud.env.extension.ImportExtraConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -22,10 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
*
*/
@SpringBootApplication
@ImportExtraConfig(name = "/Users/toava/sms.properties")
public class SmsApplication {
public static void main(String[] args) {
public static void main(String[] args) throws Exception{
SpringApplication.run(SmsApplication.class, args);
}
}

View File

@@ -4,6 +4,8 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.alicloud.sms.ISmsService;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -16,12 +18,21 @@ import com.aliyuncs.http.MethodType;
@RestController
public class SmsController {
@Autowired
private Environment environment;
@Autowired
private ISmsService smsService;
@Autowired
private SmsReportMessageListener smsReportMessageListener;
@GetMapping("/report-queue.do")
public String getSmsReportQueuename(){
return environment.getProperty("spring.cloud.alicloud.sms.up-queue-name");
}
/**
* 短信发送 Example
* @param code