多模块项目 :
父:pom
org.example
gulimmall1
pom
1.0-SNAPSHOT
gulimall-common
gulimall-coupon
gulimall-gateway
gulimall-member
gulimall-order
gulimall-product
gulimall-ware
配置中心:
引入父依赖;
gulimmall1 org.example 1.0-SNAPSHOT 4.0.0 gulimall-common10 Greenwich.SR3 org.springframework.boot spring-boot-starter-web2.6.7 org.mybatis.spring.boot mybatis-spring-boot-starter2.2.1 org.projectlombok lombok1.18.8 org.apache.httpcomponents httpcore4.4.12 commons-lang commons-lang2.6 mysql mysql-connector-java8.0.17 javax.servlet servlet-api2.5 provided com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discoverycom.alibaba.cloud spring-cloud-starter-alibaba-nacos-configcom.alibaba fastjson1.2.15 org.apache.httpcomponents httpclient4.2.1 org.apache.httpcomponents httpcore4.2.1 commons-lang commons-lang2.6 org.eclipse.jetty jetty-util9.3.7.v20160115 com.alibaba.cloud spring-cloud-starter-alibaba-sentinelorg.springframework.cloud spring-cloud-starter-zipkinorg.springframework.cloud spring-cloud-dependencies${spring-cloud.version} pom import com.alibaba.cloud spring-cloud-alibaba-dependencies2.1.0.RELEASE pom import
子模块:
org.springframework.boot spring-boot-starter-parent 2.1.8.RELEASE 4.0.0 gulimall-coupon 1.8 Greenwich.SR3 org.example gulimall-common 1.0-SNAPSHOT
配置中心:
注意配置中心的名字:
application:
name: gulimall-product
cloud:
nacos:
discovery:
server-addr: 192.168.31.190:8848
再启动类中加上注解:
@SpringBootApplication
@EnableDiscoveryClient //服务发现
public class Main {
public static void main(String[] args) {
SpringApplication.run( Main.class,args );
}
}



