1.Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded
今天用IDEA搞springboot项目,一直报错Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded,搜了半天来回改,还是一直报错,直到我猛然看到一个视频弹幕说yml配置时:后面要放一个空格!!!我意识到自己好像没放,一检查我所有句子都没有空格,我哭死,改了之后成功解决。
2. 运行报错500:ERROR 14232 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException:
Error querying database. Cause: java.sql.SQLException: No database selected
### The error may exist in com/example/demo/mapper/UserMapper.java (best guess) ### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id,no,name,password,sex,phone,role_id,isvalid FROM user
### Cause: java.sql.SQLException: No database selected ; uncategorized SQLException; SQL state [3D000]; error code [1046]; No database selected; nested exception is java.sql.
SQLException: No database selected] with root cause
我又搜了半天,看到一个博主说要在yml的url路径里写上数据库名!!!我写上之后成功解决问题。如下图test是数据库名。