JAVA全系列 教程
3762个小节阅读:7094.6k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
创建名为shopping_category_service
的SpringBoot工程,添加相关依赖。
xxxxxxxxxx
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- MyBatisPlus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.0</version>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.itbaizhan</groupId>
<artifactId>shopping_common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- dubbo -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.7.8</version>
</dependency>
<!-- 操作zookeeper -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
设置该工程的父工程为shopping
。
xxxxxxxxxx
<parent>
<groupId>com.itbaizhan</groupId>
<artifactId>shopping</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
给shopping
工程设置子模块
xxxxxxxxxx
<!-- 子模块 -->
<modules>
<!-- 广告服务 -->
<module>shopping_category_service</module>
</modules>
编写配置文件application.yml
xxxxxxxxxx
# 端口号
server:
port: 9004
# 日志格式
logging:
pattern:
console: '%d{HH:mm:ss.SSS} %clr(%-5level) --- [%-15thread] %cyan(%-50logger{50}):%msg%n'
# 配置Mybatis-plus
mybatis-plus:
global-config:
db-config:
# 表名前缀
table-prefix: bz_
# 主键生成策略为自增
id-type: auto
configuration:
# 关闭列名自动驼峰命名映射规则
map-underscore-to-camel-case: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 开启sql日志
spring:
# 数据源
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql:///baizhanshopping?serverTimezone=UTC
username: root
password: root
dubbo:
application:
name: shopping_category_service # 项目名
registry:
address: zookeeper://192.168.0.159 # 注册中心地址
port: 2181 # 注册中心端口号
timeout: 10000 # 注册到zk上超市时间,ms
protocol:
name: dubbo # dubbo使用的协议
port: -1 # 自动分配端口
scan:
base-packages: com.itbaizhan.shopping_category_service.service # 包扫描
启动类扫描Mapper包
xxxxxxxxxx
@SpringBootApplication
@MapperScan("com.itbaizhan.shopping_category_service.mapper")
public class ShoppingCategoryServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ShoppingCategoryServiceApplication.class, args);
}
}