当前位置:网站首页>Implementation of Nacos server source code
Implementation of Nacos server source code
2022-06-22 05:38:00 【fastjson_】
download nacos Source code
1、 Just keep nacos console modular , Other modules can be deleted
2、console Description of source code structure
├── pom.xml
└── src
├── main
│ ├── java
│ │ └── com
│ │ └── alibaba
│ │ └── nacos
│ │ ├── Nacos.java # main Start class
│ │ └── console # Console related source code
│ └── resources
│ ├── application.properties # nacos The configuration file
│ └── static # Static page directory
└── test # Unit test part 3、 modify Nacos.java class
Add class configuration class :ConfigConstants
/**
* @author lengleng
* @date 2019-10-31
* <p>
* Cover nacos The default configuration
*/
public interface ConfigConstants {
/**
* The System property name of Standalone mode
*/
String STANDALONE_MODE = "nacos.standalone";
/**
* Whether to turn on authentication
*/
String AUTH_ENABLED = "nacos.core.auth.enabled";
/**
* Log directory
*/
String LOG_BASEDIR = "server.tomcat.basedir";
}Mainly in the main Add Two parameters , Is it a stand-alone startup & Whether to turn off permission verification
@SpringBootApplication(scanBasePackages = "com.alibaba.nacos")
@ServletComponentScan
@EnableScheduling
public class Nacos {
public static void main(String[] args) {
if (initEnv()) {
SpringApplication.run(Nacos.class, args);
}
}
/**
* Initialize the running environment
*/
private static boolean initEnv() {
System.setProperty(ConfigConstants.STANDALONE_MODE, "true");
System.setProperty(ConfigConstants.AUTH_ENABLED, "false");
System.setProperty(ConfigConstants.LOG_BASEDIR, "logs");
System.setProperty(ConfigConstants.LOG_ENABLED, "false");
return true;
}
}modify console/pom.xml
- Because it is not in use nacos bom management , You need to add version numbers to all dependent coordinates
- because nacos-config /nacos-naming Wait until the package is not uploaded to the central reference Can't download to ,groupId Changed to:
com.pig4cloud.nacosYou can download it. - After the change, refer to the following
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nacos.version>2.0.4</nacos.version>
</properties>
<dependencies>
<dependency>
<groupId>io.springboot.nacos</groupId>
<artifactId>nacos-config</artifactId>
<version>${nacos.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>io.springboot.nacos</groupId>
<artifactId>nacos-naming</artifactId>
<version>${nacos.version}</version>
</dependency>
<dependency>
<groupId>io.springboot.nacos</groupId>
<artifactId>nacos-istio</artifactId>
<version>${nacos.version}</version>
</dependency>
</dependencies>summary
- The above modified source code reference : https://gitee.com/log4j/pig
- Whether to run in the form of source code , Different people have different opinions on this issue According to your actual situation
边栏推荐
- 代码走查的优化方向(接口请求便捷、动态class判断条件过长、去除无用console、抽离公共方法)
- 【云原生】2.2 kubeadm创建集群
- Tensorflow 2.x(keras)源码详解之第十四章:keras中的回调及自定义回调
- C语言指针(进阶)
- QEMU ARM interrupt system architecture 2
- Summary of knapsack problem
- The postmanutils tool class simulates the get and post requests of postman
- MinGW下载安装
- 中小企业签署ERP合同时,需要留意这几点
- CLion安装下载
猜你喜欢
随机推荐
总有人问我:独立站该怎么玩?3个案例,你看完就懂了
Sourcetree reported an error SSH failure
SCM future employment development direction, learn SCM must know some entry-level knowledge and industry prospects, read the benefit
Zhiyuan OA vulnerability analysis, utilization and protection collection
Overview analysis and investment forecast report of semiconductor refrigeration devices in the world and China 2022-2027
Does the air valve perform the en 1634-1 fire resistance test for 4 hours?
Conversion between JSON, string and map
网络、IO流、反射、多线程、异常
Go语言使用JWT
Talk about MySQL's locking rule "hard hitting MySQL series 15"
Talk about MySQL's locking rule "hard hitting MySQL series 15"
Global and Chinese carbon conductive filler market demand trend and future prospect report 2022-2027
毕业季 | 新的开始,不说再见
Innosetup method for judging that the program has run
Independent station optimization list - how to effectively improve the conversion rate in the station?
Online text code comparison tool
Someone always asks me: how to play independent station? Three cases, you will understand after reading
基于WebUploader实现大文件分片上传
关于背包问题的总结
LeetCode热题 HOT1-50









