前提:已经查看jdbc端口,地址,用户名密码全都正确,但是数据库依然连接不上
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private chances.cms.content.mgmt.autoArrange.ArrangeRuleRepository chances.cms.content.mgmt.autoArrange.ArrangeCategoryTask.arrangeRuleRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'arrangeRuleRepository': Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [0]; Cannot create PoolableConnectionFactory (null, message from server: "Host '10.30.57.51' is not allowed to connect to this MariaDB server"); nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (null, message from server: "Host '10.30.57.51' is not allowed to connect to this MariaDB server")
注意到这个:
"Host '10.30.57.51' is not allowed to connect to this MariaDB server"
在填写数据库配置文件时,root用户,用的是ip,也就是写ip是不行的,如果要用ip ,则要赋予权限
解决方案:
1:mysql root 一般允许本机访问 也就是localhost
所以把Ip改为localhost即可
2:创建一个远程访问的用户
grant all privileges on *.* to 'testuser'@'10.30.57.51' identified by 'testpassword' with grant option;解决
[if !supportLists]4.[endif]可以ping到ip地址,ssh 到 服务器地址 ,然后wget -c tomcat 的地址
也可以ping到,但是tomcat连接不上
解决方法:可能是防火墙开了
systemctl stop firewalld
service iptables stop
关闭防火墙,解决