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:
@@ -59,6 +59,11 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alicloud-sms</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>alibaba.com</groupId>
|
||||
<artifactId>env-extension</artifactId>
|
||||
<version>0.2.2.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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
|
||||
|
@@ -1,9 +1,4 @@
|
||||
spring.application.name=sca-sms-example
|
||||
server.port=9051
|
||||
# config management
|
||||
management.endpoints.web.exposure.include=*
|
||||
#config sms
|
||||
spring.cloud.alicloud.access-key=******
|
||||
spring.cloud.alicloud.secret-key=******
|
||||
spring.cloud.alicloud.sms.report-queue-name=*****
|
||||
spring.cloud.alicloud.sms.up-queue-name=******
|
||||
management.endpoints.web.exposure.include=*
|
Reference in New Issue
Block a user