当前位置:   article > 正文

觉哥java网站搭建笔记——后端开发环境搭建_网页后端java spring boot配置

网页后端java spring boot配置

一.后端环境搭建(jdk17+springboot3.0)

1.1maven 配置文件修改

设置编译jdk的版本:

  1. <profiles>
  2. <profile>
  3. <id>jdk-17</id>
  4. <activation>
  5. <activeByDefault>true</activeByDefault>
  6. <jdk>17</jdk>
  7. </activation>
  8. <properties>
  9. <maven.compiler.source>17</maven.compiler.source>
  10. <maven.compiler.target>17</maven.compiler.target>
  11. <maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
  12. </properties>
  13. </profile>
  14. </profiles>

设置镜像仓库地址:

  1. <mirror>
  2. <id>
  3. alimaven
  4. </id>
  5. <mirrorOf>
  6. central
  7. </mirrorOf>
  8. <name>
  9. aliyun maven
  10. </name>
  11. <url>
  12. https://maven.aliyun.com/repository/central
  13. </url>
  14. </mirror>

1.2创建父工程及子模块+依赖版本设置

jdk版本选择选择本地的jdk17 然后后面的java选项选17 如果17没出来要再点下 (idea bug或者是网的问题)

 

目前初步创建 父工程 名:juegejava

子模块名 :jjorder  jjproduct  jjuser

父工程 pom 

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>3.0.0-SNAPSHOT</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>com.juege.java</groupId>
  12. <artifactId>juejue-user</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>juegejava</name>
  15. <description>聚合服务</description>
  16. <packaging>pom</packaging>
  17. <modules>
  18. <module>jjuser</module>
  19. <module>jjproduct</module>
  20. <module>jjorder</module>
  21. </modules>
  22. </project>

子模块pom,不断更新中,springboot 3.0正式发布版还没出来 现在用的snapshot版本,springcloud

中的组件都是用的最新版本 (注释了某些组件的依赖 后面用到时再引入)

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>3.0.0-SNAPSHOT</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>com.juege.java</groupId>
  12. <artifactId>juejue-order</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>jjorder</name>
  15. <description>juegejava</description>
  16. <properties>
  17. <java.version>17</java.version>
  18. <spring-cloud.version>2022.0.0-RC1</spring-cloud.version>
  19. <cloud-component.version>3.1.4</cloud-component.version>
  20. </properties>
  21. <dependencies>
  22. <dependency>
  23. <groupId>org.springframework.boot</groupId>
  24. <artifactId>spring-boot-starter-amqp</artifactId>
  25. </dependency>
  26. <!-- <dependency>-->
  27. <!-- <groupId>org.springframework.boot</groupId>-->
  28. <!-- <artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->
  29. <!-- </dependency>-->
  30. <!-- <dependency>-->
  31. <!-- <groupId>org.springframework.boot</groupId>-->
  32. <!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
  33. <!-- </dependency>-->
  34. <!-- <dependency>-->
  35. <!-- <groupId>org.springframework.boot</groupId>-->
  36. <!-- <artifactId>spring-boot-starter-data-mongodb</artifactId>-->
  37. <!-- </dependency>-->
  38. <!-- <dependency>-->
  39. <!-- <groupId>org.springframework.boot</groupId>-->
  40. <!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
  41. <!-- </dependency>-->
  42. <dependency>
  43. <groupId>org.springframework.boot</groupId>
  44. <artifactId>spring-boot-starter-quartz</artifactId>
  45. </dependency>
  46. <dependency>
  47. <groupId>mysql</groupId>
  48. <artifactId>mysql-connector-java</artifactId>
  49. </dependency>
  50. <dependency>
  51. <groupId>org.springframework.boot</groupId>
  52. <artifactId>spring-boot-starter-security</artifactId>
  53. </dependency>
  54. <dependency>
  55. <groupId>org.apache.kafka</groupId>
  56. <artifactId>kafka-streams</artifactId>
  57. </dependency>
  58. <!-- <dependency>-->
  59. <!-- <groupId>org.springframework.cloud</groupId>-->
  60. <!-- <artifactId>spring-cloud-starter-gateway</artifactId>-->
  61. <!-- <version>${cloud-component.version}</version>-->
  62. <!-- </dependency>-->
  63. <!-- <dependency>-->
  64. <!-- <groupId>org.springframework.cloud</groupId>-->
  65. <!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
  66. <!-- <version>${cloud-component.version}</version>-->
  67. <!-- </dependency>-->
  68. <!-- <dependency>-->
  69. <!-- <groupId>org.springframework.cloud</groupId>-->
  70. <!-- <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>-->
  71. <!-- <version>${cloud-component.version}</version>-->
  72. <!-- </dependency>-->
  73. <dependency>
  74. <groupId>org.springframework.cloud</groupId>
  75. <artifactId>spring-cloud-starter-openfeign</artifactId>
  76. <version>${cloud-component.version}</version>
  77. </dependency>
  78. <dependency>
  79. <groupId>org.springframework.kafka</groupId>
  80. <artifactId>spring-kafka</artifactId>
  81. </dependency>
  82. <dependency>
  83. <groupId>org.springframework.boot</groupId>
  84. <artifactId>spring-boot-devtools</artifactId>
  85. <scope>runtime</scope>
  86. <optional>true</optional>
  87. </dependency>
  88. <dependency>
  89. <groupId>org.springframework.boot</groupId>
  90. <artifactId>spring-boot-configuration-processor</artifactId>
  91. <optional>true</optional>
  92. </dependency>
  93. <dependency>
  94. <groupId>org.projectlombok</groupId>
  95. <artifactId>lombok</artifactId>
  96. <optional>true</optional>
  97. </dependency>
  98. <dependency>
  99. <groupId>org.springframework.boot</groupId>
  100. <artifactId>spring-boot-starter-test</artifactId>
  101. <scope>test</scope>
  102. </dependency>
  103. <!-- <dependency>-->
  104. <!-- <groupId>org.springframework.amqp</groupId>-->
  105. <!-- <artifactId>spring-rabbit-test</artifactId>-->
  106. <!-- <scope>test</scope>-->
  107. <!-- </dependency>-->
  108. <dependency>
  109. <groupId>org.springframework.kafka</groupId>
  110. <artifactId>spring-kafka-test</artifactId>
  111. <scope>test</scope>
  112. </dependency>
  113. <dependency>
  114. <groupId>org.springframework.security</groupId>
  115. <artifactId>spring-security-test</artifactId>
  116. <scope>test</scope>
  117. </dependency>
  118. </dependencies>
  119. <dependencyManagement>
  120. <dependencies>
  121. <dependency>
  122. <groupId>org.springframework.cloud</groupId>
  123. <artifactId>spring-cloud-dependencies</artifactId>
  124. <version>${spring-cloud.version}</version>
  125. <type>pom</type>
  126. <scope>import</scope>
  127. </dependency>
  128. </dependencies>
  129. </dependencyManagement>
  130. <!-- <build>-->
  131. <!-- <plugins>-->
  132. <!-- <plugin>-->
  133. <!-- <groupId>org.springframework.boot</groupId>-->
  134. <!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
  135. <!-- <version>2.7.5</version>-->
  136. <!-- <configuration>-->
  137. <!-- <excludes>-->
  138. <!-- <exclude>-->
  139. <!-- <groupId>org.projectlombok</groupId>-->
  140. <!-- <artifactId>lombok</artifactId>-->
  141. <!-- </exclude>-->
  142. <!-- </excludes>-->
  143. <!-- </configuration>-->
  144. <!-- </plugin>-->
  145. <!-- </plugins>-->
  146. <!-- </build>-->
  147. <repositories>
  148. <repository>
  149. <id>spring-milestones</id>
  150. <name>Spring Milestones</name>
  151. <url>https://repo.spring.io/milestone</url>
  152. <snapshots>
  153. <enabled>false</enabled>
  154. </snapshots>
  155. </repository>
  156. <repository>
  157. <id>spring-snapshots</id>
  158. <name>Spring Snapshots</name>
  159. <url>https://repo.spring.io/snapshot</url>
  160. <releases>
  161. <enabled>false</enabled>
  162. </releases>
  163. </repository>
  164. <repository>
  165. <id>netflix-candidates</id>
  166. <name>Netflix Candidates</name>
  167. <url>https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates</url>
  168. <snapshots>
  169. <enabled>false</enabled>
  170. </snapshots>
  171. </repository>
  172. </repositories>
  173. <pluginRepositories>
  174. <pluginRepository>
  175. <id>spring-milestones</id>
  176. <name>Spring Milestones</name>
  177. <url>https://repo.spring.io/milestone</url>
  178. <snapshots>
  179. <enabled>false</enabled>
  180. </snapshots>
  181. </pluginRepository>
  182. <pluginRepository>
  183. <id>spring-snapshots</id>
  184. <name>Spring Snapshots</name>
  185. <url>https://repo.spring.io/snapshot</url>
  186. <releases>
  187. <enabled>false</enabled>
  188. </releases>
  189. </pluginRepository>
  190. </pluginRepositories>
  191. </project>

1.3腾讯云server配置

防火墙  -》端口开放

 密钥,一般默认就有

1.4安装docker 并配置加速

安装 docker

配置加速

1.5 拉取常用软件镜像 及创建并运行容器

安装mysql

安装redis

配置自动重启

  1. docker update mysql --restart=always
  2. docker update redis --restart=always

1.6版本控制gitee配置

版本控制的准备(码云+git+配置SSH免密连接)

1.7建库建表需在server上进入 mysql bash控制台操作

  1. [root@localhost ~]# docker exec -it mysqlaa bash
  2. root@31e36f35d688:/# mysql -uroot -p
  3. 输入密码root

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/157147
推荐阅读
相关标签
  

闽ICP备14008679号