Amigos, vocês podem mim ajudar a resolver esse erro? Classe Configuracao
package br.com.alura.listavip;
import javax.sql.DataSource;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@SpringBootApplication
public class Configuracao {
public static void main(String[] args) {
SpringApplication.run(Configuracao.class, args);
}
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("mysql:jdbc://localhost:3306/listavip");
dataSource.setUsername("root");
dataSource.setPassword("root");
return dataSource;
}
}
Classe ConvidadoController
package br.com.alura.listavip;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import br.com.alura.model.Convidado;
import br.com.alura.repository.ConvidadoRepository;
@Controller
public class ConvidadoController {
@Autowired
private ConvidadoRepository repository;
@RequestMapping("/")
public String index() {
return "index";
}
@RequestMapping("/listaconvidados")
public String listaConvidado(Model model) {
Iterable<Convidado> convidados = repository.findAll();
model.addAttribute("Convidados", convidados);
return "listaconvidados";
}
}
Classe Convidado
package br.com.alura.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity(name = "convidado")
public class Convidado {
@Id
@GeneratedValue
private Long id;
private String nome;
private String email;
private String telefone;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.alura.listavip</groupId>
<artifactId>listavip2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>1.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>1.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
</dependencies>
</project>