总结:nacos-2.x.x要使用mysql5.7.x
项目使用若依3.1.0-cloud版本,因此要使用nacos-2.x.x的版本,下载并安装nacos后,
配置application.properties里的Config Module Related Configurations模块,
#*************** 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_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=SYC
db.password.0=123
然后再启动startup.cmd时会报错,需要使用单机模式,
编辑startup.cmd,设置里面的MODE为standalone
set MODE="standalone"
set FUNCTION_MODE="all"
set SERVER=nacos-server
set MODE_INDEX=-1
set FUNCTION_MODE_INDEX=-1
set SERVER_INDEX=-1
set EMBEDDED_STORAGE_INDEX=-1
set EMBEDDED_STORAGE=""
再次启动时报错
2022-09-09 16:30:29,073 ERROR Startup errors :
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memoryMonitor' defined in URL [jar:file:/D:/Software/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-config-2.1.1.jar!/com/alibaba/nacos/config/server/monitor/MemoryMonitor.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'asyncNotifyService': Unsatisfied dependency expressed through field 'dumpService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalDumpService': Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :
No DataSource set
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.create
看着No DataSource set猜测可能是链接数据库问题,使用的mysql为5.6.x
升级为5.7.x
再次启动成功
"nacos is starting with standalone"
,--.
,--.'|
,--,: : | Nacos 2.1.1
,`--.'`| ' : ,---. Running in stand alone mode, All function modules
| : : | | ' ,'\ .--.--. Port: 8848
: | \ | : ,--.--. ,---. / / | / / ' Pid: 22716
| : ' '; | / \ / \. ; ,. :| : /`./ Console: http://192.168.56.1:8848/nacos/index.html
' ' ;. ;.--. .-. | / / '' | |: :| : ;_
| | | \ | \__\/: . .. ' / ' | .; : \ \ `. https://nacos.io
' : | ; .' ," .--.; |' ; :__| : | `----. \
| | '`--' / / ,. |' | '.'|\ \ / / /`--' /
' : | ; : .' \ : : `----' '--'. /
; |.' | , .-./\ \ / `--'---'
'---' `--`---' `----'2022-09-09 16:43:26,404 INFO Tomcat initialized with port(s): 8848 (http)
2022-09-09 16:43:26,501 INFO Root WebApplicationContext: initialization completed in 2700 ms
2022-09-09 16:43:29,845 INFO Adding welcome page: class path resource [static/index.html]
2022-09-09 16:43:30,149 WARN You are asking Spring Security to ignore Ant [pattern='/**']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead.
2022-09-09 16:43:30,150 INFO Will not secure Ant [pattern='/**']
2022-09-09 16:43:30,175 INFO Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@62e70ea3, org.springframework.security.web.context.SecurityContextPersistenceFilter@186978a6, org.springframework.security.web.header.HeaderWriterFilter@34a75079, org.springframework.security.web.csrf.CsrfFilter@72a85671, org.springframework.security.web.authentication.logout.LogoutFilter@7a7471ce, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@482d776b, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@132ddbab, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3efe7086, org.springframework.security.web.session.SessionManagementFilter@107ed6fc, org.springframework.security.web.access.ExceptionTranslationFilter@631e06ab]
2022-09-09 16:43:30,195 INFO Exposing 1 endpoint(s) beneath base path '/actuator'
2022-09-09 16:43:30,238 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'
2022-09-09 16:43:30,259 INFO Nacos started successfully in stand alone mode. use external storage