[JAVA] Spring Boot + MyBatis I get this error if I don't set the database

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

If it was only Spring Boot, it worked, but when I put mybatis in dependencies, an error occurred at startup. It was because there was no data source setting.

Solution

It was solved by specifying the connection information to the database in application.properties or application.yml. If you generate a project with https://start.spring.io/, src / main / resources / application.properties will be generated, but you can also use application.yml.

In the case of MySQL, it looks like this.

application.yml


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

Recommended Posts

Spring Boot + MyBatis I get this error if I don't set the database
I want to control the default error message of Spring Boot
If you don't know Spring Framework, buy this! !! !! !! !! !!
I get Mysql2 :: Error :: ConnectionError in the production environment
05. I tried to stub the source of Spring Boot
I tried to reduce the capacity of Spring Boot
Get error information using DefaultErrorAttributes and ErrorAttributeOptions in Spring Boot 2.3
I tried to get started with Swagger using Spring Boot
[Spring Boot] I want to add my own property file and get the value with env.getProperty ().
Set context-param in Spring Boot
Get started with Spring boot
Error in Spring database connection
Set cookies with Spring Boot
Get a proxy instance of the component itself in Spring Boot
02. I made an API to connect to MySQL (MyBatis) from Spring Boot
What I did in the migration from Spring Boot 1.4 series to 2.0 series
What I did in the migration from Spring Boot 1.5 series to 2.0 series
I don't see an error in Rails bundle install ... the solution
If you get tired of "Spring Boot", why not try "jooby"?