UserServerApplication.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.keao.edu.user;
  2. import com.huifu.adapay.Adapay;
  3. import com.huifu.adapay.model.MerConfig;
  4. import com.keao.edu.thirdparty.adapay.ConfigInit;
  5. import com.keao.edu.user.service.NotifyCallback;
  6. import com.spring4all.swagger.EnableSwagger2Doc;
  7. import org.mybatis.spring.annotation.MapperScan;
  8. import org.springframework.boot.SpringApplication;
  9. import org.springframework.boot.autoconfigure.SpringBootApplication;
  10. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  11. import org.springframework.cloud.client.loadbalancer.LoadBalanced;
  12. import org.springframework.cloud.openfeign.EnableFeignClients;
  13. import org.springframework.context.annotation.Bean;
  14. import org.springframework.context.annotation.ComponentScan;
  15. import org.springframework.context.annotation.Configuration;
  16. import org.springframework.scheduling.annotation.EnableAsync;
  17. import org.springframework.web.client.RestTemplate;
  18. @SpringBootApplication
  19. @EnableDiscoveryClient
  20. @EnableFeignClients({"com.keao.edu"})
  21. @MapperScan({"com.keao.edu.user.dao"})
  22. @ComponentScan(basePackages="com.keao.edu")
  23. @Configuration
  24. @EnableSwagger2Doc
  25. @EnableAsync
  26. public class UserServerApplication {
  27. public static void main(String[] args) {
  28. SpringApplication.run(UserServerApplication.class, args);
  29. }
  30. @Bean
  31. @LoadBalanced
  32. public RestTemplate restTemplate() {
  33. return new RestTemplate();
  34. }
  35. @Bean
  36. public static void startMqtt() {
  37. MerConfig merConfig = ConfigInit.merConfig;
  38. NotifyCallback notifyCallback = new NotifyCallback();
  39. try {
  40. Adapay.startMqttListener(merConfig, notifyCallback);
  41. } catch (Exception e) {
  42. e.printStackTrace();
  43. }
  44. }
  45. }