JAVA全系列 教程
3762个小节阅读:7095.1k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
接下来我们创建文件服务模块,编写文件上传和文件删除的服务。
创建名为shopping_file_service
的SpringBoot工程,添加相关依赖。
xxxxxxxxxx
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</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>
<!-- FastDFS -->
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.26.5</version>
</dependency>
</dependencies>
设置该工程的父工程为shopping
。
xxxxxxxxxx
<parent>
<groupId>com.itbaizhan</groupId>
<artifactId>shopping</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
给shopping
工程设置子模块
xxxxxxxxxx
<!-- 子模块 -->
<modules>
<!-- 文件服务 -->
<module>shopping_file_service</module>
</modules>
编写配置文件application.yml
xxxxxxxxxx
# 端口号
server:
port: 9003
# 日志格式
logging:
pattern:
console: '%d{HH:mm:ss.SSS} %clr(%-5level) --- [%-15thread] %cyan(%-50logger{50}):%msg%n'
dubbo:
application:
name: shopping_file_service # 项目名
registry:
address: zookeeper://192.168.25.100 # 注册中心地址
port: 2181 # 注册中心的端口
timeout: 10000 # 注册到zk上超时时间,ms
protocol:
name: dubbo # dubbo使用的协议
port: -1 # dubbo自动分配端口
scan:
base-packages: com.itbaizhan.shopping_file_service.service # 包扫描
fdfs:
so-timeout: 3000
connect-timeout: 6000
tracker-list: # TrackerList路径
- 192.168.0.159:22122
fileUrl: http://192.168.0.159 # 自定义配置,文件访问路径
启动类忽略数据源自动配置
xxxxxxxxxx
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
public class ShoppingFileServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ShoppingFileServiceApplication.class, args);
}
}