克隆源码
在github上搜索nancos,克隆代码,详细不再赘述。
搭建maven环境
百度搜索,也不再赘述。
下载源码
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
程序入口
在console模块下
└─src
├─main
│ ├─java
│ │ └─com
│ │ └─alibaba
│ │ └─nacos
│ │ └─console
| | ├─**Nacos.java**
│ │ ├─config
│ │ ├─controller
│ │ ├─exception
│ │ ├─filter
│ │ ├─model
│ │ ├─security
│ │ │ └─nacos
│ │ │ ├─roles
│ │ │ └─users
│ │ └─utils
@SpringBootApplication(scanBasePackages = "com.alibaba.nacos")
@ServletComponentScan
@EnableScheduling
public class Nacos {
public static void main(String[] args) {
SpringApplication.run(Nacos.class, args);
}
}
导入数据库
在distribution\conf下有nacos-mysql.sql,导入
├─distribution
│ ├─bin
│ └─conf
修改配置文件
### If use MySQL as datasource:
spring.datasource.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=root
db.password.0=czy123456
修改命令参数
修改vm option参数,单机模式
-Dnacos.standalone=true -Dnacos.home=D:/DevelopData/JavaProject/nacos/distribution
启动
2021-06-13 19:03:39.586 INFO 10440 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@38a1a26' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-06-13 19:03:39.595 INFO 10440 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-06-13 19:03:40.239 INFO 10440 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8848 (http)
有这些log就表示成功了。