Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <dependencies>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- </dependency>
- </dependencies>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>2.1.4.RELEASE</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- @Entity
- public class Person {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Integer id;
- @Column(name = "name")
- private String name;
- @Column(name = "last_name")
- private String lastName;
- @Column(name = "age")
- private Integer age;
- @Column(name = "createdAt")
- @Temporal(TemporalType.TIMESTAMP)
- private Date createdAt;
- ...
- }
- @Repository
- public interface PersonRepository extends CrudRepository<Person, Integer> {
- }
- @SpringBootApplication
- public class SpringDataApplication {
- public static void main(String[] args) throws Exception {
- ConfigurableApplicationContext context = SpringApplication.run(SpringDataApplication.class, args);
- PersonRepository personRepository = context.getBean(PersonRepository.class);
- Person p1 = new Person("Juan", "Camaney", 55);
- Person p2 = new Person("Arturo", "Lopez", 33);
- Person p3 = new Person("Pancho", "Coscorin", 22);
- personRepository.save(p1);
- personRepository.save(p2);
- personRepository.save(p3);
- Iterator<Person> people = personRepository.findAll().iterator();
- while (people.hasNext()) {
- Person temp = people.next();
- System.out.println(temp);
- }
- }
- }
- Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.devs4j.spring.data.repositories.PersonRepository' available
- @Configuration
- @EnableJpaRepositories("com.devs4j.spring.data.repositories")
- public class JpaConfiguration {
- }
- EnableJpaRepositories cannot be resolved to a type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement