阿里注册中心 Nacos 启动报错 Unable to start web server

1020阅读 0评论2022-06-07 fhadmin
分类:Java


点击(此处)折叠或打开


  1. 报错内容如下

  2. org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
  3.         at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156)
  4.         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
  5.         at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
  6.         at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
  7.         at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
  8.         at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
  9.         at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
  10.         at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
  11.         at com.alibaba.nacos.Nacos.main(Nacos.java:35)
  12.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  13.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  14.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  15.         at java.lang.reflect.Method.invoke(Method.java:483)
  16.         at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
  17.         at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
  18.         at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
  19.         at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
  20. Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
  21.         at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:124)
  22.         at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86)
  23.         at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:416)
  24.         at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:180)
  25.         at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180)
  26.         at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153)
  27.         ... 16 common frames omitted
  28. (spring cloud alibaba项目源码 from fhadmin.cn)

  29. 因为如果直接在 bin 目录下用鼠标双击 startup.cmd 启动的话,默认的是以 cluster (集群) 的方式启动,直接启动第一个会报 Unable to start embedded Tomcat 错误,改成单机启动:

  30. 用记事本打开 bin 目录下查看 startup.cmd

  31. @echo off
  32. rem Copyright 1999-2018 Alibaba Group Holding Ltd.
  33. rem Licensed under the Apache License, Version 2.0 (the "License");
  34. rem you may not use this file except in compliance with the License.
  35. rem You may obtain a copy of the License at
  36. rem
  37. rem http://www.apache.org/licenses/LICENSE-2.0
  38. rem
  39. rem Unless required by applicable law or agreed to in writing, software
  40. rem distributed under the License is distributed on an "AS IS" BASIS,
  41. rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  42. rem See the License for the specific language governing permissions and
  43. rem limitations under the License.
  44. if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is & EXIT /B 1
  45. set "JAVA=%JAVA_HOME%\bin\java.exe"
  46.  
  47. setlocal enabledelayedexpansion
  48.  
  49. set BASE_DIR=%~dp0
  50. rem added double quotation marks to avoid the issue caused by the folder names containing spaces.
  51. rem removed the last 5 chars(which means \bin\) to get the base DIR.
  52. set BASE_DIR="%BASE_DIR:~0,-5%"
  53.  
  54. set CUSTOM_SEARCH_LOCATIONS=file:%BASE_DIR%/conf/
  55.  
  56. set MODE="standalone"
  57. set FUNCTION_MODE="all"
  58. set SERVER=nacos-server
  59. set MODE_INDEX=-1
  60. set FUNCTION_MODE_INDEX=-1
  61. set SERVER_INDEX=-1
  62. set EMBEDDED_STORAGE_INDEX=-1
  63. set EMBEDDED_STORAGE=""
  64.  

  65. 把 set MODE="cluster" 改为 set MODE="standalone" 即可


上一篇:springcloud 整合 druid 阿里的数据库连接池
下一篇:spring boot html+vue.js 形式前后分离代码示例