微服务模块

1、建module

image.png
image.png
image.png
image.png
可以看出父项目添加了modules

2、改pom

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-starter-web</artifactId>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.springframework.boot</groupId>
  8. <artifactId>spring-boot-starter-actuator</artifactId>
  9. </dependency>
  10. <dependency>
  11. <groupId>org.mybatis.spring.boot</groupId>
  12. <artifactId>mybatis-spring-boot-starter</artifactId>
  13. </dependency>
  14. <dependency>
  15. <groupId>com.alibaba</groupId>
  16. <artifactId>druid-spring-boot-starter</artifactId>
  17. <version>1.1.10</version>
  18. </dependency>
  19. <!-- mysql-connector-java-->
  20. <dependency>
  21. <groupId>mysql</groupId>
  22. <artifactId>mysql-connector-java</artifactId>
  23. </dependency>
  24. <!-- jdbc-->
  25. <dependency>
  26. <groupId>org.springframework.boot</groupId>
  27. <artifactId>spring-boot-starter-jdbc</artifactId>
  28. </dependency>
  29. </dependencies>

3、写YML

  1. server:
  2. port: 8001
  3. spring:
  4. application:
  5. name: cloud-payment-service
  6. datasource:
  7. type: com.alibaba.druid.pool.DruidDataSource
  8. driver-class-name: org.gjt.mm.mysql.Driver
  9. url: jdbc:mysql://localhost:3306/user_db?useUnicode=true&characterEncoding=utf-8&useSSL=false
  10. username: root
  11. password: root
  12. mybatis:
  13. mapper-locations: classpath:mapper/*.xml
  14. type-aliases-package: com.zxd.springcloud.entities #所有Entity别名类所在包

4、主启动

  1. package com.zxd.springcloud;
  2. import org.springframework.boot.SpringApplication;
  3. import org.springframework.boot.autoconfigure.SpringBootApplication;
  4. @SpringBootApplication
  5. public class PaymentMain8001 {
  6. public static void main(String[] args) {
  7. SpringApplication.run(PaymentMain8001.class,args);
  8. }
  9. }

5、业务类

1、建表SQL

2、entities

1、主实体Payment

2、Json封装体CommonResult

3、dao

4、service

5、controller