2

springAlibaba实践(9)----Nacos项目配置

 1 year ago
source link: http://www.blogjava.net/zzsuje/archive/2022/05/06/450737.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

springAlibaba实践(9)----Nacos项目配置

9.1. 依赖引入 Nacos Discovery Starter
 首先,修改 common中的pom.xml 文件。
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency> 
9.2.使用 @EnableDiscoveryClient 注解开启服务注册与发现功能
@SpringBootApplication
@MapperScan("com.yxj.gulimall.coupon.dao")
@EnableDiscoveryClient
public class GulimallCouponApplication {
public static void main(String[] args)
{
  SpringApplication.run(GulimallCouponApplication.class, args);

}
3.在应用的common中的application.yml 配置文件中配置 Nacos Server 地址和微服务名称
spring:
  application:
    name: gulimall-coupon
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://192.168.100.106:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: root
  cloud:
    nacos:
      discovery:
        server-addr: 192.168.100.106:8848
发表于 2022-05-06 11:35 zzsuje 阅读(2) 评论(0)  编辑  收藏

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK