访问Tomcat内的项目时出现:“404访问tomcat下的项目源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示”。
解决办法:
- 查看tomcat的logs目录下的localhost.time.log日志文件
- 找到有缩进的at开头的row的前面一句错误信息
- 报错为“java.sql.SQLException: null, message from server: "Host '192.xxx.xxx.xxx' is not allowed to connect to this MySQL server"”
- 原因是:远程服务器不允许你的java程序访问它的数据库。所以,我们要对远程服务器进行设置,使它允许你进行连接。
- 在mysql的bin目录下打开命令行,登录数据库mysql -u root -p
- 输入user mysql;
- 再输入select host,user from user;
- 再输入update user set host ='%' where user ='root';
- 最后重新启动MySQL服务