1.引入依赖parent

  1. <!-- 所有的版本管理交给父级 -->
  2. <parent>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-starter-parent</artifactId>
  5. <version>2.3.3.RELEASE</version>
  6. <relativePath/> <!-- lookup parent from repository -->
  7. </parent>

2.设置资源属性

  1. <!-- 设置资源属性-->
  2. <properties>
  3. <java.version>1.8</java.version>
  4. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  5. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  6. </properties>

3.引入依赖dependency

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-starter</artifactId>
  5. <!-- 排除logging(规避漏洞)后续会整合其他的日志 -->
  6. <exclusions>
  7. <exclusion>
  8. <groupId>org.springframework.boot</groupId>
  9. <artifactId>spring-boot-starter-logging</artifactId>
  10. </exclusion>
  11. </exclusions>
  12. </dependency>
  13. <dependency>
  14. <groupId>org.springframework.boot</groupId>
  15. <artifactId>spring-boot-starter-web</artifactId>
  16. <!-- 打包war [2] 移除内置tomcat -->
  17. <!--<exclusions>
  18. <exclusion>
  19. <artifactId>spring-boot-starter-tomcat</artifactId>
  20. <groupId>org.springframework.boot</groupId>
  21. </exclusion>
  22. </exclusions>-->
  23. </dependency>
  24. <!-- 打包war [3] 添加依赖 -->
  25. <!--<dependency>
  26. <groupId>javax.servlet</groupId>
  27. <artifactId>javax.servlet-api</artifactId>
  28. <scope>provided</scope>
  29. </dependency>-->
  30. <!-- 项目默认会解析yml文件,想要解析其他文件如xml,properties需要引入这个依赖 -->
  31. <dependency>
  32. <groupId>org.springframework.boot</groupId>
  33. <artifactId>spring-boot-configuration-processor</artifactId>
  34. <optional>true</optional>
  35. </dependency>
  36. </dependencies>

4. 全部依赖

  1. <!--
  2. 1. 聚合工程里可以分为顶级项目(顶级工程、父工程)与子工程,这两者的关系其实就是父子继承的关系
  3. 子工程在maven里称之为模块(module),模块之间是平级,是可以相互依赖的。
  4. 2. 子模块可以使用顶级工程里所有的资源(依赖),子模块之间如果要使用资源,必须构建依赖(构建关系)
  5. 3. 一个顶级工程是可以由多个不同的子工程共同组合而成。
  6. -->
  7. <parent>
  8. <groupId>org.springframework.boot</groupId>
  9. <artifactId>spring-boot-starter-parent</artifactId>
  10. <version>2.5.8</version>
  11. <relativePath/> <!-- lookup parent from repository -->
  12. </parent>
  13. <groupId>cn.myst.web</groupId>
  14. <artifactId>foodie-shop</artifactId>
  15. <version>0.0.1-SNAPSHOT</version>
  16. <name>foodie-shop</name>
  17. <description>Demo project for Spring Boot</description>
  18. <properties>
  19. <java.version>1.8</java.version>
  20. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  21. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  22. </properties>
  23. <dependencies>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter</artifactId>
  27. <!-- 排除logging(规避漏洞) -->
  28. <exclusions>
  29. <exclusion>
  30. <groupId>org.springframework.boot</groupId>
  31. <artifactId>spring-boot-starter-logging</artifactId>
  32. </exclusion>
  33. </exclusions>
  34. </dependency>
  35. <dependency>
  36. <groupId>org.springframework.boot</groupId>
  37. <artifactId>spring-boot-starter-web</artifactId>
  38. <!-- 打包war [2] 移除内置tomcat -->
  39. <!--<exclusions>
  40. <exclusion>
  41. <artifactId>spring-boot-starter-tomcat</artifactId>
  42. <groupId>org.springframework.boot</groupId>
  43. </exclusion>
  44. </exclusions>-->
  45. </dependency>
  46. <!-- 打包war [3] 添加依赖 -->
  47. <!--<dependency>
  48. <groupId>javax.servlet</groupId>
  49. <artifactId>javax.servlet-api</artifactId>
  50. <scope>provided</scope>
  51. </dependency>-->
  52. <dependency>
  53. <groupId>org.mybatis.spring.boot</groupId>
  54. <artifactId>mybatis-spring-boot-starter</artifactId>
  55. <version>2.2.0</version>
  56. </dependency>
  57. <dependency>
  58. <groupId>mysql</groupId>
  59. <artifactId>mysql-connector-java</artifactId>
  60. <scope>runtime</scope>
  61. </dependency>
  62. <dependency>
  63. <groupId>org.springframework.boot</groupId>
  64. <artifactId>spring-boot-configuration-processor</artifactId>
  65. <optional>true</optional>
  66. </dependency>
  67. <dependency>
  68. <groupId>org.projectlombok</groupId>
  69. <artifactId>lombok</artifactId>
  70. <optional>true</optional>
  71. </dependency>
  72. <dependency>
  73. <groupId>org.springframework.boot</groupId>
  74. <artifactId>spring-boot-starter-test</artifactId>
  75. <scope>test</scope>
  76. </dependency>
  77. <dependency>
  78. <groupId>org.springframework.boot</groupId>
  79. <artifactId>spring-boot-starter-aop</artifactId>
  80. </dependency>
  81. <dependency>
  82. <groupId>org.springframework.boot</groupId>
  83. <artifactId>spring-boot-starter-validation</artifactId>
  84. </dependency>
  85. <dependency>
  86. <groupId>org.springframework.boot</groupId>
  87. <artifactId>spring-boot-starter-data-redis</artifactId>
  88. </dependency>
  89. <!-- https://mvnrepository.com/artifact/org.redisson/redisson-spring-boot-starter -->
  90. <dependency>
  91. <groupId>org.redisson</groupId>
  92. <artifactId>redisson-spring-boot-starter</artifactId>
  93. <version>3.16.7</version>
  94. </dependency>
  95. <!-- https://mvnrepository.com/artifact/org.springframework.session/spring-session-data-redis -->
  96. <!-- <dependency>-->
  97. <!-- <groupId>org.springframework.session</groupId>-->
  98. <!-- <artifactId>spring-session-data-redis</artifactId>-->
  99. <!-- </dependency>-->
  100. <!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security &ndash;&gt;-->
  101. <!-- <dependency>-->
  102. <!-- <groupId>org.springframework.boot</groupId>-->
  103. <!-- <artifactId>spring-boot-starter-security</artifactId>-->
  104. <!-- </dependency>-->
  105. <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
  106. <dependency>
  107. <groupId>com.alibaba</groupId>
  108. <artifactId>fastjson</artifactId>
  109. <version>1.2.79</version>
  110. </dependency>
  111. <!-- Mybatis Plus -->
  112. <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
  113. <dependency>
  114. <groupId>com.baomidou</groupId>
  115. <artifactId>mybatis-plus-boot-starter</artifactId>
  116. <version>3.4.3.4</version>
  117. </dependency>
  118. <!-- Swagger UI -->
  119. <!-- https://mvnrepository.com/artifact/io.springfox/springfox-boot-starter -->
  120. <dependency>
  121. <groupId>io.springfox</groupId>
  122. <artifactId>springfox-boot-starter</artifactId>
  123. <version>3.0.0</version>
  124. </dependency>
  125. <!-- 分页插件 -->
  126. <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter -->
  127. <dependency>
  128. <groupId>com.github.pagehelper</groupId>
  129. <artifactId>pagehelper-spring-boot-starter</artifactId>
  130. <version>1.4.1</version>
  131. </dependency>
  132. <!-- 用于Java的谷歌核心库 -->
  133. <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
  134. <dependency>
  135. <groupId>com.google.guava</groupId>
  136. <artifactId>guava</artifactId>
  137. <version>31.0.1-jre</version>
  138. </dependency>
  139. <!-- apache 工具类 类如用户名检验-->
  140. <!-- 文件检测 -->
  141. <!-- https://mvnrepository.com/artifact/org.apache.tika/tika-core -->
  142. <dependency>
  143. <groupId>org.apache.tika</groupId>
  144. <artifactId>tika-core</artifactId>
  145. <version>2.2.1</version>
  146. </dependency>
  147. <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
  148. <dependency>
  149. <groupId>commons-codec</groupId>
  150. <artifactId>commons-codec</artifactId>
  151. <version>1.15</version>
  152. </dependency>
  153. <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
  154. <dependency>
  155. <groupId>org.apache.commons</groupId>
  156. <artifactId>commons-lang3</artifactId>
  157. <version>3.12.0</version>
  158. </dependency>
  159. <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
  160. <dependency>
  161. <groupId>commons-io</groupId>
  162. <artifactId>commons-io</artifactId>
  163. <version>2.11.0</version>
  164. </dependency>
  165. </dependencies>
  166. <build>
  167. <plugins>
  168. <plugin>
  169. <groupId>org.springframework.boot</groupId>
  170. <artifactId>spring-boot-maven-plugin</artifactId>
  171. <configuration>
  172. <excludes>
  173. <exclude>
  174. <groupId>org.projectlombok</groupId>
  175. <artifactId>lombok</artifactId>
  176. </exclude>
  177. </excludes>
  178. <!-- 开启skip,多模块项目需先clean,后install package -->
  179. <skip>true</skip>
  180. </configuration>
  181. </plugin>
  182. </plugins>
  183. </build>