pom文件相关配置
<!-- 模块版本 --> <modelVersion>4.0.0</modelVersion> <!-- 父级项目 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.9</version> <relativePath/> <!-- lookup parent from repository --> </parent> <!-- 当前项目的参数 --> <groupId>cn.tedu</groupId> <artifactId>csmall-product</artifactId> <version>0.0.1</version> <!-- 属性配置 --> <properties> <java.version>1.8</java.version> </properties>
<dependencies>
<!--Spring AOP, 用于实现AOP编程--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency>
<!--Spring Data Redis,用于实现Redis编程--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency>
<!-- fastjson:实现对象与JSON的相互转换 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.75</version> </dependency>
<!-- JJWT(Java JWT) --> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.9.1</version> </dependency> <!-- Spring Security,用于处理认证与授权 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
<!-- 摘要加密算法依赖项 --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.10</version> </dependency> <!-- Spring Boot的基础依赖项 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
<!-- Spring Boot Validation,用于检查请求参数的基本格式 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <!-- Mybatis整合Spring Boot的依赖项 --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.2</version> </dependency> <!-- MySQL的依赖项 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <!-- Lombok的依赖项,主要用于简化POJO类的编写 --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.20</version> <scope>provided</scope> </dependency> <!-- Spring Boot测试的依赖项 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
<!-- 当前项目使用的依赖项 --> <!-- scope > test:此依赖项仅用于测试,则此依赖项不会被打包,并且这些依赖项在src/main中不可用 --> <!-- scope > runtime:此依赖项仅在运行时需要,即编写代码时并不需要此依赖项 -->
<!-- Knife4j Spring Boot:在线API
完成后,启动项目,通过 http://localhost:9081/doc.html 即可访问在线API文档!
--> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>2.0.9</version> </dependency> </dependencies>
yml相关配置
# 连接数据库的配置 spring: datasource: url: jdbc:mysql://localhost:3306/mall_ams?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Chongqing username: root password: root
# 日志的显示级别 logging: level: cn.tedu.csmall: trace
# 服务端口 server: port: 9080
spring: # Profile配置文件的相关配置 profiles: # 激活哪个Profile配置 active: dev
spring: # Jackson框架相关配置 jackson: # JSON结果中是否包含为null的属性的默认配置 default-property-inclusion: non_null
# 配置Mybatis的XML文件的位置 mybatis: mapper-locations: classpath:mapper/*.xml
# 自定义配置 csmall: # JWT相关配置 jwt: # 签名算法中使用的盐 secret-key: dahsuikASafdsjhludasASFD # JWT的有效时长 duration-in-minute: 14400
spring: application: name: nacos-stock # 定义当前服务名称 cloud: nacos: discovery: server-addr: localhost:8848 # 指定正在运行的Nacos服务器的位置
#公共配置 mybatis: configuration: cache-enabled: false map-underscore-to-camel-case: true log-impl: org.apache.ibatis.logging.stdout.StdOutImpl knife4j: # 开启增强配置 enable: true # 生产环境屏蔽,开启将禁止访问在线API文档 production: false # Basic认证功能,即是否需要通过用户名、密码验证后才可以访问在线API文档 basic: # 是否开启Basic认证 enable: false # 用户名,如果开启Basic认证却未配置用户名与密码,默认是:admin/123321 username: root # 密码 password: root
dubbo: protocol: # port设置为-1 表示当前dubbo框架使用的端口自动寻找 # 使用端口的规则是从20880开始寻找可用端口,如果当前端口号被占用,则每次+1,直到找到可用端口为止 port: -1 # 设置连接的名称, 一般固定为dubbo即可 name: dubbo registry: # 指定当前Dubbo服务注册中心的类型和位置 address: nacos://localhost:8848 consumer: # 当前项目启动时,是否检查当前项目需要的所有dubbo服务是否可用 # 我们设置它为false,表示不检查,以减少启动时出错的情况 check: false