框架环境:
编译工具:idea
java jdk(1.8)
maven 3.3.9
以上点环境需求自己下载安装即可(百度一坨)
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-03-04 22:19:44.362 ERROR 5956 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Disconnected from the target VM, address: '127.0.0.1:59455', transport: 'socket'
Process finished with exit code 1
下面的才是关键 : 我们有数据源却没有配置( 我们在创建项目的时候 现在了mybatis + mysql 所以才有这个提示 :先不着急配置 然后注掉 pom文件中的mybatis和 mysql )
先定一个小目标 用springboot完成一个helloworld 之后再下一步学习(所以先注释掉pom文件中的数据源) 注释掉后以下点问题得以解决![](https://i-blog.csdnimg.cn/blog_migrate/3f21f5cefc7cb6c4d69dba0d64e53668.png)
成功启动了
然后开心访问:
原因1:(我的问题就是目录结构不对, 于是修改一番)
Application启动类的位置不对.要将Application类放在最外侧,即包含所有子包
原因:spring-boot会自动加载启动类所在包下及其子包下的所有组件.
原因2:
在springboot的配置文件:application.yml或application.properties中关于视图解析器的配置问题:
当pom文件下的spring-boot-starter-paren版本高时使用:
spring.mvc.view.prefix/spring.mvc.view.suffix
当pom文件下的spring-boot-starter-paren版本低时使用:
spring.view.prefix/spring.view.suffix
原因3:
requestMapping 写的和访问路径不一致
再次启动: 请求成功