Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-17 16:02:00.613 ERROR 21000 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method inicio in mx.com.gm.ControladorInicio required a bean of type 'org.springframework.ui.Model' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.ui.Model' in your configuration.
Alguien sabe a que se debe? Les dejo mi codigo
Código
package mx.com.gm; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Configuration; @SpringBootApplication public class HolaSpringApplication { SpringApplication.run(HolaSpringApplication.class, args); } } package mx.com.gm; import java.util.ArrayList; import java.util.Arrays; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import lombok.extern.java.Log; import lombok.extern.slf4j.Slf4j; import mx.com.gm.dominio.Persona; @Controller public class ControladorInicio { private PersonaDao personadao; @GetMapping("/") @Autowired var personas = personadao.findAll(); model.addAttribute("personas", personas); return "index"; } } package mx.com.gm.dominio; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; //import lombok.Data; //@Data private static final long SerialVersionUID= 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) return nombre; } this.nombre = nombre; } return apellido; } this.apellido = apellido; } return email; } this.email = email; } } package mx.com.gm; import org.springframework.data.repository.CrudRepository; import mx.com.gm.dominio.Persona; public interface PersonaDao extends CrudRepository<Persona, Integer>{ } mi pom.xml <?xml version="1.0" encoding="UTF-8"?> <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>mx.com.gm</groupId> <artifactId>HolaMundoSpringData</artifactId> <version>1.0</version> <name>HolaMundoSpringData</name> <description>HolaMundo con Spring</description> <properties> <java.version>13</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> application.properti: spring.datasource.url=jdbc:mysql://localhost:3306/spring?zeroDateTimeBehavior=convertToNull&useSSL=false&useTimezone=true&serverTimezone=UTC&allowPublicKeyRetrieval=true spring.datasource.username=root spring.datasource.password=123777 spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect spring.jpa.properties.hibernate.format_sql=true logging.level.org.hibernate.SQL=DEBUG logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
Código
<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <table border= "1"> <tr> </tr> <tr th:each="persona : ${personas}"> </tr> </table> </body> </html>