本文介绍从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
复制代码 创建一个自己的分支,用于保存笔记和代码注释:本地编译
- 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
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |