Nacos源码 (1) 源码编译及idea环境

31 篇文章 2 订阅
7 篇文章 0 订阅

本文介绍从gitee下载nacos源码,在本地编译,并导入idea进行本地调试。


系列文章:
Nacos源码 (2) 核心模块
Nacos源码 (3) 注册中心
Nacos源码 (4) 配置中心
Nacos源码 (5) Grpc服务端和客户端



从gitee下载源码

由于github访问速度慢,所以我选择使用gitee的镜像仓库:

git clone https://gitee.com/mirrors/Nacos.git

本文使用2.0.2版本,所以需要切换到2.0.2分支:

cd Nacos
git checkout 2.0.2

创建一个自己的分支,用于保存笔记和代码注释:

git checkout -b my-2.0.2

本地编译

mvn -Dmaven.test.skip=true -Drat.skip=true clean install

构建发布包

mvn -Prelease-nacos -Dmaven.test.skip=true -Drat.skip=true clean install -U

这种构建方式会在distribution/target目录下生成nacos-server-2.0.2.zip包,从官网下载的就是这样的包。

但是会抛错:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.0:repackage (default) on project nacos-console: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.1.0:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.1.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

将工程使用的spring-boot-maven-plugin版本改成2.3.8.RELEASE版本即可:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.3.8.RELEASE</version>
</plugin>

idea开发环境

导入到idea

File -> Open导入即可。

启动console

找到console/src/main/java/com/alibaba/nacos/console/config/ConsoleConfig.java文件,修改PropertySource注解值:

// @PropertySource("/application.properties")
@PropertySource("classpath:application.properties")
public class ConsoleConfig {

/application.properties改为classpath:application.properties。

需要添加一些环境变量和参数:

  • -Dnacos.standalone=true
  • –logging.config=classpath:nacos-logback.xml

如果需要自定义日志就使用–logging.config指定配置文件路径。

访问console

http://localhost:8848/nacos

用户名:nacos

密码:nacos

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值