Criei o projeto utilizando o Spring Initializr e nele ja adicionei a dependencia do myseql-connector. O mesmo esta presente no arquivo pom.xml.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class TestaConexao {
public static void main(String[] args) throws SQLException {
Connection connection = DriverManager.getConnection(
"jdbc:mysql://localhost/loja_virtual?useTimezone=true&serverTimezone=UTC",
"root",
"minhasenha");
connection.close();
}
}
Porem, ainda recebo o erro:
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).
Process finished with exit code 1