设为首页 加入收藏

TOP

Nacos源码 (1) 源码编译及idea环境
2023-08-06 07:49:55 】 浏览:48
Tags:Nacos 源码 idea 环境

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

从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

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇浏览器中的自动化操作插件:Automa 下一篇编译器、链接器和解释器

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目