首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring boot启动错误

Spring boot启动错误
EN

Stack Overflow用户
提问于 2018-05-03 13:45:26
回答 2查看 3.4K关注 0票数 0

当我尝试运行spring boot应用程序时,我得到了以下错误

代码语言:javascript
复制
starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2018-05-03 10:50:09.457 ERROR 4909 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

*************************** APPLICATION FAILED TO START
***************************

Description:

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-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).
EN

回答 2

Stack Overflow用户

发布于 2018-05-03 14:01:43

如果您想要使用非嵌入式数据源,上述答案是正确的。如果要使用嵌入式数据源,则只需向pom.xml添加以下依赖项

代码语言:javascript
复制
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
</dependency>

如果您想在测试中使用嵌入式数据源,那么将作用域更改为test而不是runtime。

票数 4
EN

Stack Overflow用户

发布于 2018-05-03 13:54:09

如果您希望自动配置数据源,请将配置详细信息放在application.properties文件中。如下所示(MySQL的配置)

代码语言:javascript
复制
spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=dbuser
spring.datasource.password=dbpass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50147762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档