当前位置:   article > 正文

spring-boot开发微信小程序后台(一)_微信小程序 后台是war 还是jar

微信小程序 后台是war 还是jar

spring-boot开发微信小程序后台

本次开发使用spring聚合工程,大概如下 

common层:类似枚举类,工具类都放在该层

pojo层:项目实体类

mapper(dao)层:数据库操作

server层:逻辑

api层:接口

自下而上逐级依赖

步骤:

新建父项目,既parent框架,拿我手头项目为例:

父项目在选择打包方式时,要选择pom而不是war或者jar

 panshi-studio为整体parent

parent/pom.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>cn.jxau</groupId>
  4. <artifactId>panshi-studio</artifactId>
  5. <version>0.0.1-SNAPSHOT</version>
  6. <packaging>pom</packaging>
  7. <build/>
  8. <name>磐石工作室微信小程序</name>
  9. <parent>
  10. <groupId>org.springframework.boot</groupId>
  11. <artifactId>spring-boot-starter-parent</artifactId>
  12. <version>1.5.12.RELEASE</version>
  13. <relativePath/>
  14. </parent>
  15. <properties>
  16. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  17. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  18. <java.version>1.8</java.version>
  19. </properties>
  20. <modules>
  21. <module>common</module>
  22. <module>panshi-studio-common</module>
  23. <module>panshi-studio-pojo</module>
  24. <module>panshi-studio-dao</module>
  25. <module>panshi-studio-service</module>
  26. <module>panshi-studio-api</module>
  27. </modules>
  28. </project>

基本就是设置spring boot版本 编码格式 还有一些模块信息

common/pom.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <parent>
  4. <groupId>cn.jxau</groupId>
  5. <artifactId>panshi-studio</artifactId>
  6. <version>0.0.1-SNAPSHOT</version>
  7. </parent>
  8. <artifactId>panshi-studio-common</artifactId>
  9. <properties>
  10. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  11. </properties>
  12. <dependencies>
  13. <dependency>
  14. <groupId>org.springframework.boot</groupId>
  15. <artifactId>spring-boot-starter</artifactId>
  16. <exclusions>
  17. <!-- 排除springboot默认的logback日志框架 -->
  18. <exclusion>
  19. <groupId>org.springframework.boot</groupId>
  20. <artifactId>spring-boot-starter-logging</artifactId>
  21. </exclusion>
  22. </exclusions>
  23. </dependency>
  24. <!-- 引入log4j日志依赖 -->
  25. <dependency>
  26. <groupId>org.springframework.boot</groupId>
  27. <artifactId>spring-boot-starter-log4j</artifactId>
  28. <version>1.3.8.RELEASE</version>
  29. </dependency>
  30. <!-- 引入spring aop依赖 -->
  31. <dependency>
  32. <groupId>org.springframework.boot</groupId>
  33. <artifactId>spring-boot-starter-aop</artifactId>
  34. </dependency>
  35. <dependency>
  36. <groupId>org.springframework.boot</groupId>
  37. <artifactId>spring-boot-starter-web</artifactId>
  38. <exclusions>
  39. </exclusions>
  40. </dependency>
  41. <!-- 资源配置 -->
  42. <dependency>
  43. <groupId>org.springframework.boot</groupId>
  44. <artifactId>spring-boot-configuration-processor</artifactId>
  45. <optional>true</optional>
  46. </dependency>
  47. <dependency>
  48. <groupId>org.springframework.boot</groupId>
  49. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  50. </dependency>
  51. <!-- 阿里开源数据源 -->
  52. <dependency>
  53. <groupId>com.alibaba</groupId>
  54. <artifactId>druid</artifactId>
  55. <version>1.1.0</version>
  56. </dependency>
  57. <dependency>
  58. <groupId>com.alibaba</groupId>
  59. <artifactId>druid-spring-boot-starter</artifactId>
  60. <version>1.1.0</version>
  61. </dependency>
  62. <dependency>
  63. <groupId>mysql</groupId>
  64. <artifactId>mysql-connector-java</artifactId>
  65. <version>5.1.41</version>
  66. </dependency>
  67. <!-- mybatis -->
  68. <dependency>
  69. <groupId>org.mybatis.spring.boot</groupId>
  70. <artifactId>mybatis-spring-boot-starter</artifactId>
  71. <version>1.3.1</version>
  72. </dependency>
  73. <!--mapper -->
  74. <dependency>
  75. <groupId>tk.mybatis</groupId>
  76. <artifactId>mapper-spring-boot-starter</artifactId>
  77. <version>1.2.4</version>
  78. </dependency>
  79. <!--pagehelper -->
  80. <dependency>
  81. <groupId>com.github.pagehelper</groupId>
  82. <artifactId>pagehelper-spring-boot-starter</artifactId>
  83. <version>1.2.3</version>
  84. </dependency>
  85. <!-- apache 工具类 -->
  86. <dependency>
  87. <groupId>commons-codec</groupId>
  88. <artifactId>commons-codec</artifactId>
  89. <version>1.11</version>
  90. </dependency>
  91. <dependency>
  92. <groupId>org.apache.commons</groupId>
  93. <artifactId>commons-lang3</artifactId>
  94. <version>3.4</version>
  95. </dependency>
  96. <dependency>
  97. <groupId>org.apache.commons</groupId>
  98. <artifactId>commons-io</artifactId>
  99. <version>1.3.2</version>
  100. </dependency>
  101. <!-- swagger2 配置 -->
  102. <dependency>
  103. <groupId>io.springfox</groupId>
  104. <artifactId>springfox-swagger2</artifactId>
  105. <version>2.4.0</version>
  106. </dependency>
  107. <dependency>
  108. <groupId>io.springfox</groupId>
  109. <artifactId>springfox-swagger-ui</artifactId>
  110. <version>2.4.0</version>
  111. </dependency>
  112. <!-- 引入 redis 依赖 -->
  113. <dependency>
  114. <groupId>org.springframework.boot</groupId>
  115. <artifactId>spring-boot-starter-data-redis</artifactId>
  116. </dependency>
  117. <dependency>
  118. <groupId>redis.clients</groupId>
  119. <artifactId>jedis</artifactId>
  120. <version>2.9.0</version>
  121. </dependency>
  122. <dependency>
  123. <groupId>org.springframework.data</groupId>
  124. <artifactId>spring-data-redis</artifactId>
  125. <version>1.8.7.RELEASE</version>
  126. </dependency>
  127. </dependencies>
  128. </project>

项目所用的的所有依赖都在common这一层中写出,因为后面各个模块都会依赖common所以后面不用写这些了。

创建模块,及设置依赖步骤:

右键parent,选择新建maven module

 

next,填写模块名称,finish:

找到新建模块的pom.xml,双击,操作如下图

next:在输入框中填写所要依赖的模块名,在结果中选择想要的,点击ok:

 一个模块就完成了,创建和依赖

pojo/pom.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <parent>
  4. <groupId>cn.jxau</groupId>
  5. <artifactId>panshi-studio</artifactId>
  6. <version>0.0.1-SNAPSHOT</version>
  7. </parent>
  8. <artifactId>panshi-studio-pojo</artifactId>
  9. <build/>
  10. <dependencies>
  11. <dependency>
  12. <groupId>cn.jxau</groupId>
  13. <artifactId>panshi-studio-common</artifactId>
  14. <version>0.0.1-SNAPSHOT</version>
  15. </dependency>
  16. </dependencies>
  17. </project>

mapper(dao)/pom.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <parent>
  4. <groupId>cn.jxau</groupId>
  5. <artifactId>panshi-studio</artifactId>
  6. <version>0.0.1-SNAPSHOT</version>
  7. </parent>
  8. <artifactId>panshi-studio-dao</artifactId>
  9. <build/>
  10. <dependencies>
  11. <dependency>
  12. <groupId>cn.jxau</groupId>
  13. <artifactId>panshi-studio-pojo</artifactId>
  14. <version>0.0.1-SNAPSHOT</version>
  15. </dependency>
  16. </dependencies>
  17. </project>

service/pom.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <parent>
  4. <groupId>cn.jxau</groupId>
  5. <artifactId>panshi-studio</artifactId>
  6. <version>0.0.1-SNAPSHOT</version>
  7. </parent>
  8. <artifactId>panshi-studio-service</artifactId>
  9. <build/>
  10. <dependencies>
  11. <dependency>
  12. <groupId>cn.jxau</groupId>
  13. <artifactId>panshi-studio-dao</artifactId>
  14. <version>0.0.1-SNAPSHOT</version>
  15. </dependency>
  16. </dependencies>
  17. </project>

api/pom.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <parent>
  4. <groupId>cn.jxau</groupId>
  5. <artifactId>panshi-studio</artifactId>
  6. <version>0.0.1-SNAPSHOT</version>
  7. </parent>
  8. <artifactId>panshi-studio-api</artifactId>
  9. <build/>
  10. <dependencies>
  11. <dependency>
  12. <groupId>cn.jxau</groupId>
  13. <artifactId>panshi-studio-service</artifactId>
  14. <version>0.0.1-SNAPSHOT</version>
  15. </dependency>
  16. </dependencies>
  17. </project>

这样一个spring boot聚合工程就大致完成了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/209774
推荐阅读
相关标签
  

闽ICP备14008679号