关于mysql数据库连接异常处理
tomcat启动错误⽇志关键信息:
28-Aug-2019 14:22:55.014 SEVERE [localhost-startStop-1] org.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.ContainerBase.addChildInternal(ContainerBase.java:743)
at org.ContainerBase.addChild(ContainerBase.java:719)
at org.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1125)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1859)
at urrent.Executors$RunnableAdapter.call(Executors.java:511)
at urrent.FutureTask.run(FutureTask.java:266)
at urrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
mysql下载starting the server
at urrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: t.ApplicationContextException: Unable to start web server; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cxfConfig': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'busiServices': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AICCropServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lvAttach
mentImplService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'attachmentMapper' defined in file [/usr/local/develop/wechat-tomcat/apache-tomcat-8.5.43/webapps/ROOT/WEB-INF/classes/com/dhht/dao/AttachmentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception ptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 144 milliseconds ago. The last packet sent successfully to the server was 137 milliseconds ago.
at org.springframework.boot.Refresh(ServletWebServerApplicationContext.java:155)
at t.fresh(AbstractApplicationContext.java:544)
at org.springframework.boot.fresh(ServletWebServerApplicationContext.java:140)
at org.springframework.fresh(SpringApplication.java:759)
at org.springframework.freshContext(SpringApplication.java:395)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:155)
at org.springframework.boot.web.servlet.ateRootApplicationContext(SpringBootServletInitializer.java:135)
at org.springframework.boot.web.servlet.Startup(SpringBootServletInitializer.java:87)
at org.springframework.Startup(SpringServletContainerInitializer.java:172)
at org.StandardContext.startInternal(StandardContext.java:5154)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cxfConfig': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'busiServices': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AICCropServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lvAttach
mentImplService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'attachmentMapper' defined in file [/usr/local/develop/wechat-tomcat/apache-tomcat-8.5.43/webapps/ROOT/WEB-
INF/classes/com/dhht/dao/AttachmentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource
[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource
[com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is
The last packet successfully received from the server was 144 milliseconds ago. The last packet sent successfully to the server was 137 milliseconds ago.
at t.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:578)
at org.springframework.beans.factory.ateBean(AbstractAutowireCapableBeanFactory.java:501)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.Singleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.Bean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) at org.springframework.beans.factory.ateBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541)
at org.springframework.beans.factory.ateBean(AbstractAutowireCapableBeanFactory.java:501)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.Singleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.Bean(AbstractBeanFactory.java:204)
at org.springframework.boot.web.OrderedBeansOfType(ServletContextInitializerBeans.java:225)
at org.springframework.boot.web.OrderedBeansOfType(ServletContextInitializerBeans.java:213)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:90)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:79)
at
org.springframework.boot.ServletContextInitializerBeans(ServletWebServerApplicationContext.java:250) at org.springframework.boot.t.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:237)
at org.springframework.boot.ateWebServer(ServletWebServerApplicationContext.java:183)
at org.springframework.boot.Refresh(ServletWebServerApplicationContext.java:152)
... 21 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'busiServices': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AICCrop
ServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lvAttachmentImplService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'attachmentMapper' defined in file [/usr/local/develop/wechat-tomcat/apache-tomcat-8.5.43/webapps/ROOT/WEB-
INF/classes/com/dhht/dao/AttachmentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource
[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource
[com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of ini
t method failed; nested exception is
--原因:mysql没有配置ssl加密,连接池连接的时候默认加密了
--war包数据库配置⽂件修改如下:(对⽐注释)
# jdbc:mysql://127.0.0.1:13306/pro_hnyz_db?useSSL=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
url: jdbc:mysql://127.0.0.1:13306/pro_hnyz_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false
username: root

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。