3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Spring Boot + MyBatis データベース設定ないとこんなエラー出る

Posted at
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).

Spring Bootだけなら動いたのにdependenciesにmybatis入れると起動時にエラーが出た。
データソースの設定がないからだった。

解決

application.propertiesもしくはapplication.ymlにデータベースへの接続情報を指定すると解消した。
https://start.spring.io/ でプロジェクト生成するとsrc/main/resources/application.propertiesが生成されるがapplication.ymlにしてもOK。

MySQLの場合はこんな感じ。

application.yml
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/mysql
    username: devusr
    password: devpass
    driver-class-name: com.mysql.cj.jdbc.Driver
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?