摘要:
主要是完成点评项目的搭建,以及aplication.yaml文件的填写修改,主要包括数据库连接,redis连接配置
1,aplication.yaml文件
如果是较新版本jdk或者springboot依赖,yaml文件会提示redis的写法过时,所以需要修改一下:
spring:
data:
redis:
host: 192.168.xxx.xxx
port: 6379
password: xxxx
lettuce:
pool:
max-active: 10
max-idle: 10
min-idle: 1
time-between-eviction-runs: 10s
database: 1 #默认库为0,自行选择
2,修改pom文件,添加了javax的annotation和servlet的api
点评项目默认的jdk(1.8)和springboot(2.x.x)版本较老,我这里就jdk21进行了更新,主要是springboot依赖,mybatisplus依赖(再次强调springboot与mybatisplus版本一定要匹配!!!)
如果还是不清楚自己的版本问题可以参考springboot和mybatisplus的版本匹配与整合问题:Invalid bean definition with name ‘xxxMapper‘ defined in flle解决方法_invalid bean defintion with name trunipmapper defi-优快云博客
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.10</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.hmdp</groupId>
<artifactId>hm-dianping</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>hm-dianping</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.7</version>
</dependency>
<!--hutool-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.17</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
3,前后端联调http://127.0.0.1:8080
输入网址,然后点击开发者工具,将浏览器转换为手机模式