After starting the application faylitsya. I can not understand what the error is. I moved the Internet, but something has not yet found the answer. Here is a description:
Description: Field userRepository in com.pro100denysko.app.resttest.controller.UserController required a bean of type 'com.pro100denysko.app.resttest.service.UserRepository' that could not be found. Action: Consider defining a bean of type 'com.pro100denysko.app.resttest.service.UserRepository' in your configuration. Here is the controller:
package com.pro100denysko.app.resttest.controller; import com.pro100denysko.app.resttest.model.User; import com.pro100denysko.app.resttest.service.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController @RequestMapping("/users") public class UserController { @Autowired UserRepository userRepository; @RequestMapping(value = "/listOfUsers", method = RequestMethod.GET) @ResponseBody public List<User> findAll() { return userRepository.findAll(); } } Here is the model:
package com.pro100denysko.app.resttest.model; import lombok.Data; import javax.persistence.*; @Entity @Table(name = "users") public @Data class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ID") private int id; @Column(name = "NAME") private String name; @Column(name = "LASTNAME") private String lastName; @Column(name = "AGE") private int age; } Here is the repository service:
package com.pro100denysko.app.resttest.service; import com.pro100denysko.app.resttest.model.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository("UserRepository") public interface UserRepository extends JpaRepository<User, Integer> { } Well, Maine himself:
package com.pro100denysko.app.resttest; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @ComponentScan(basePackages = {"com.pro100denysko.app.resttest"}) @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class}) public class RestTestApplication { public static void main(String[] args) { SpringApplication.run(RestTestApplication.class, args); } }
RestTestApplication@EnableJpaRepositories on@EnableJpaRepositories(basePackages = {"com.pro100denysko.app.resttest"})- Nofate ♦Consider defining a bean named 'entityManagerFactory' in your configuration. - Pro100Denysko