项目场景:

准备使用nacos做配置中心,版本1.3.1(官方推荐稳定版本–2021-01-11)
mysql版本:5.7版本(听说5.8改动很大),否则运行不了nacos-mysql.sql文件
JDK版本:1.8.0_144(版本低了也不行)


问题描述:

1、本地idea运行spring cloud alibaba nacos源码报错Unable to start embedded Tomcat

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:157)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
	at com.alibaba.nacos.Nacos.main(Nacos.java:35)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:125)
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86)
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:414)
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154)
	... 8 common frames omitted

原因分析:

网上百度这个问题,答案有说是配置文件的问题,application.properties配置文件修改

#*************** Config Module Related Configurations ***************#
### 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=root
db.password=root

解决方案:

idea的解决方案
源码下载到了本地,导入idea,没有报错什么的(虽然导入的时候会提示找不到各种类什么的)启动类在console模块中,需要修改这个模块的application.properties,修改方法和nacos server的配置文件修改方法一样,Nacos本地源码构建启动,如果不是集群方式启动,需要在启动参数增加-Dnacos.standalone=true。
1、点击右上角的Edit Configurations
1
2、在弹出的界面中,VM options输入-Dnacos.standalone=true,保存即可。
在这里插入图片描述

Logo

更多推荐