paicoding
paicoding copied to clipboard
启动报错
Connected to the target VM, address: '127.0.0.1:1210', transport: 'socket' 08:55:46.754 [main] DEBUG reactor.util.Loggers - Using Slf4j logging framework 08:55:46.759 [main] DEBUG reactor.core.publisher.Hooks - Enabling stacktrace debugging via onOperatorDebug 08:55:47.545 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@77ecfa48
| __ \ /\ |_ | / | / __ \ | __ \ | | | \ | | / | | |__) | / \ | | | | | | | | | | | | | | | | | | | __ | / / /\ \ | | | | | | | | | | | | | | | . ` | | | | | | | / ____ \ | | | | | || | | || | | | | |\ | | |__| | || // _\ |_____| _| _/ |/ |__| || _| ____|
:: 技术派 https://paicoding.com :: 欢迎关注公众号: (楼仔 | 沉默王二) :: SpringBoot 2.7.1
2023-12-21 08:55:48,618 [restartedMain] INFO |||c.g.p.f.web.QuickForumApplication.logStarting(StartupInfoLogger.java:55) - Starting QuickForumApplication using Java 17.0.9 on Fan-ThinkBook with PID 29592 2023-12-21 08:55:48,620 [restartedMain] INFO |||c.g.p.f.web.QuickForumApplication.logStartupProfileInfo(SpringApplication.java:634) - No active profile set, falling back to 1 default profile: "default"
2023-12-21 08:55:48,700 [restartedMain] INFO |||o.s.b.d.e.DevToolsPropertyDefaultsPostProcessor.logTo(DeferredLog.java:255) - Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-12-21 08:55:48,700 [restartedMain] INFO |||o.s.b.d.e.DevToolsPropertyDefaultsPostProcessor.logTo(DeferredLog.java:255) - For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-12-21 08:55:50,862 [restartedMain] INFO |||o.s.d.r.c.RepositoryConfigurationDelegate.multipleStoresDetected(RepositoryConfigurationDelegate.java:262) - Multiple Spring Data modules found, entering strict repository configuration mode
2023-12-21 08:55:50,868 [restartedMain] INFO |||o.s.d.r.c.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:132) - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2023-12-21 08:55:50,953 [restartedMain] INFO |||o.s.d.r.c.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:201) - Finished Spring Data repository scanning in 64 ms. Found 0 Redis repository interfaces.
2023-12-21 08:55:51,286 [restartedMain] WARN |||o.m.s.mapper.ClassPathMapperScanner.warn(Logger.java:44) - No MyBatis mapper was found in '[com.github.paicoding.forum.web]' package. Please check your configuration.
2023-12-21 08:55:53,184 [restartedMain] INFO |||c.g.p.f.c.senstive.SensitiveService.refresh(SensitiveService.java:50) - 敏感词初始化完成!
_ _ |_ _ |. ___ _ | _
| | |/|)(| | |\ |)|||\
/ |
3.4.3.4
2023-12-21 08:55:55,765 [restartedMain] INFO |||o.s.b.w.e.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:108) - Tomcat initialized with port(s): 8080 (http)
2023-12-21 08:55:55,780 [restartedMain] INFO |||o.a.coyote.http11.Http11NioProtocol.log(DirectJDKLog.java:173) - Initializing ProtocolHandler ["http-nio-8080"]
2023-12-21 08:55:55,781 [restartedMain] INFO |||o.a.catalina.core.StandardService.log(DirectJDKLog.java:173) - Starting service [Tomcat]
2023-12-21 08:55:55,782 [restartedMain] INFO |||o.a.catalina.core.StandardEngine.log(DirectJDKLog.java:173) - Starting Servlet engine: [Apache Tomcat/9.0.64]
2023-12-21 08:55:56,049 [restartedMain] INFO |||o.a.c.c.C.[Tomcat].[localhost].[/].log(DirectJDKLog.java:173) - Initializing Spring embedded WebApplicationContext
2023-12-21 08:55:56,049 [restartedMain] INFO |||o.s.b.w.s.c.ServletWebServerApplicationContext.prepareWebApplicationContext(ServletWebServerApplicationContext.java:292) - Root WebApplicationContext: initialization completed in 7348 ms
2023-12-21 08:55:56,748 [restartedMain] INFO |||c.g.p.forum.web.config.PaiWebConfig.init(PaiWebConfig.java:39) - PaiWebConfig init...
2023-12-21 08:55:56,758 [restartedMain] INFO |||c.g.p.forum.web.config.PaiWebConfig.init(PaiWebConfig.java:70) - WebConfig init 设置jackson序列化long为字符串成功!!!
2023-12-21 08:55:57,191 [restartedMain] INFO |||c.g.p.f.s.c.s.i.c.ChatGptIntegration.init(ChatGptIntegration.java:82) - ChatGpt配置初始化完成: ChatGptIntegration.ChatGptConfig(main=CHAT_GPT_3_5, conf={CHAT_GPT_3_5=ChatGptIntegration.GptConf(keys=[], proxy=true, apiHost=https://api.openai.com/, timeOut=900, maxToken=3000), CHAT_GPT_4=ChatGptIntegration.GptConf(keys=[], proxy=true, apiHost=https://api.openai.com/, timeOut=900, maxToken=200000)})
2023-12-21 08:55:58,632 [restartedMain] WARN |||o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext.refresh(AbstractApplicationContext.java:591) - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceInitializer' defined in class path resource [com/github/paicoding/forum/web/config/init/ForumDataSourceInitializer.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jdbc.datasource.init.DataSourceInitializer]: Factory method 'dataSourceInitializer' threw exception; nested exception is java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
2023-12-21 08:55:58,646 [restartedMain] INFO |||o.a.catalina.core.StandardService.log(DirectJDKLog.java:173) - Stopping service [Tomcat]
2023-12-21 08:55:58,664 [restartedMain] INFO |||o.s.b.a.l.ConditionEvaluationReportLoggingListener.logMessage(ConditionEvaluationReportLoggingListener.java:136) -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-12-21 08:55:58,748 [restartedMain] ERROR|||o.s.boot.SpringApplication.reportFailure(SpringApplication.java:824) - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceInitializer' defined in class path resource [com/github/paicoding/forum/web/config/init/ForumDataSourceInitializer.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jdbc.datasource.init.DataSourceInitializer]: Factory method 'dataSourceInitializer' threw exception; nested exception is java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
at com.github.paicoding.forum.web.QuickForumApplication.main(QuickForumApplication.java:60)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jdbc.datasource.init.DataSourceInitializer]: Factory method 'dataSourceInitializer' threw exception; nested exception is java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
... 24 common frames omitted
Caused by: java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at com.github.paicoding.forum.web.config.init.ForumDataSourceInitializer.autoInitDatabase(ForumDataSourceInitializer.java:115)
at com.github.paicoding.forum.web.config.init.ForumDataSourceInitializer.needInit(ForumDataSourceInitializer.java:77)
at com.github.paicoding.forum.web.config.init.ForumDataSourceInitializer.dataSourceInitializer(ForumDataSourceInitializer.java:51)
at com.github.paicoding.forum.web.config.init.ForumDataSourceInitializer$$EnhancerBySpringCGLIB$$3439a055.CGLIB$dataSourceInitializer$0(
Process finished with exit code 0
数据库连不上,提示已经很明显了
解决了吗?我也遇到这个问题了,可是数据库名字和密码都是正确的啊,一直连不上
解决了吗?我也遇到这个问题了,可是数据库名字和密码都是正确的啊,一直连不上
贴一些错误提示,这种相对明显的异常大概率就是数据库的相关配置不对,或者因为虚拟机 or 容器的原因导致应用访问不了数据库
注意数据库有三处需要配置,而且配置完不要在MySQL中创建对应database.name的数据库,只要能让程序连接上数据库即可,之后会自动建库建表添加数据,如果提前创建了对应名称的空数据库,程序启动时会直接进行查询导致启动失败