mall商城笔记-02
项目的搭建
一、搭建父工程
- 这里要注意父工程的boot版本与cloud版本的对照,否则无法启动
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-parent</artifactId>
<version>3.2.1</version>
</parent>
<!--springcloud的版本控制-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2023.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
二、搭建Eureka
- 添加依赖
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
- 开启服务
@SpringBootApplication
@EnableEurekaServer // 开启Eureka服务
public class EurekaApplication
{
public static void main( String[] args )
{
SpringApplication.run(EurekaApplication.class,args);
}
}
- 配置文件
server:
port: 7001
eureka:
instance:
hostname: 127.0.0.1
client:
register-with-eureka: false #是否将自己注册到eureka中
fetch-registry: false #是否从eureka中获取信息
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
spring:
application:
name: eureka
世界上没有什么事情是跑步解决不了的,如果有,那就再跑一会!