title: No property findOne() found for type class User
body: <p>I have searched many pages but didnt found the answer so i paste the whole code.I am testing the testclass and getting the error like "Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract org.home.mysystem.entity.User org.home.mysystem.repository.UserRepository.findOne(java.lang.String)! No property findOne found for type User!". Please someone help me</p>
  
  <p>Role.java</p>
  
  <pre><code>package org.home.mysystem.entity;
  
  import java.util.List;
  
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.ManyToMany;
  
  @Entity
  public class Role {
  
      @Id
      private String name;
      @ManyToMany(mappedBy = "roles")
      private List&lt;User&gt; users;
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public List&lt;User&gt; getUsers() {
          return users;
      }
  
      public void setUsers(List&lt;User&gt; users) {
          this.users = users;
      }
  
      public Role(String name, List&lt;User&gt; users) {
          this.name = name;
          this.users = users;
      }
  
      public Role() {
      }
  
      public Role(String name) {
          this.name = name;
      }
  
  }
  </code></pre>
  
  <p>Task.java</p>
  
  <pre><code>package org.home.mysystem.entity;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.ManyToOne;
  
  import org.hibernate.validator.constraints.NotEmpty;
  
  @Entity
  public class Task {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      @NotEmpty
      private String date;
      @NotEmpty
      private String startTime;
      @NotEmpty
      private String stopTime;
      @NotEmpty
      @Column(length=1000)
      private String description;
      @ManyToOne
      @JoinColumn(name="USER_EMAIL")
      private User user;
  
      public Long getId() {
          return id;
      }
      public void setId(Long id) {
          this.id = id;
      }
      public String getDate() {
          return date;
      }
      public void setDate(String date) {
          this.date = date;
      }
      public String getStartTime() {
          return startTime;
      }
      public void setStartTime(String startTime) {
          this.startTime = startTime;
      }
      public String getStopTime() {
          return stopTime;
      }
      public void setStopTime(String stopTime) {
          this.stopTime = stopTime;
      }
      public String getDescription() {
          return description;
      }
      public void setDescription(String description) {
          this.description = description;
      }
      public User getUser() {
          return user;
      }
      public void setUser(User user) {
          this.user = user;
      }
      public Task(String date, String startTime, String stopTime, String description, User user) {
          this.date = date;
          this.startTime = startTime;
          this.stopTime = stopTime;
          this.description = description;
          this.user = user;
      }
      public Task(String date, String startTime, String stopTime, String description) {
          this.date = date;
          this.startTime = startTime;
          this.stopTime = stopTime;
          this.description = description;
      }
      public Task() {
      }
  
  
  
  }
  </code></pre>
  
  <p>User.java</p>
  
  <pre><code>package org.home.mysystem.entity;
  
  import java.util.List;
  
  import javax.persistence.CascadeType;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.JoinTable;
  import javax.persistence.ManyToMany;
  import javax.persistence.OneToMany;
  import javax.validation.constraints.Size;
  
  import org.hibernate.validator.constraints.Email;
  import org.hibernate.validator.constraints.NotEmpty;
  
  @Entity
  public class User {
  
      @Id
      @Email
      @NotEmpty
      @Column(unique = true)
      private String email;
      @NotEmpty
      private String name;
      @Size(min = 4)
      private String password;
      @OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
      private List&lt;Task&gt; tasks;
  
      @ManyToMany(cascade = CascadeType.ALL)
      @JoinTable(name = "USER_ROLES", joinColumns={
              @JoinColumn(name = "USER_EMAIL", referencedColumnName = "email") }, inverseJoinColumns = {
                      @JoinColumn(name = "ROLE_NAME", referencedColumnName = "name") })
      private List&lt;Role&gt; roles;
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public List&lt;Task&gt; gettasks() {
          return tasks;
      }
  
      public void settasks(List&lt;Task&gt; tasks) {
          this.tasks = tasks;
      }
  
      public List&lt;Role&gt; getRoles() {
          return roles;
      }
  
      public void setRoles(List&lt;Role&gt; roles) {
          this.roles = roles;
      }
  
      public User(String email, String name, String password) {
          this.email = email;
          this.name = name;
          this.password = password;
      }
  
      public User() {
  
      }
  
  }
  </code></pre>
  
  <p>RoleRepository.java</p>
  
  <pre><code>    package org.home.mysystem.repository;
  
      import org.home.mysystem.entity.Role;
      import org.springframework.data.jpa.repository.JpaRepository;
  
      public interface RoleRepository extends JpaRepository&lt;Role, String&gt; {
  
      }
  </code></pre>
  
  <p>TaskRepository.java</p>
  
  <pre><code> public interface TaskRepository extends JpaRepository&lt;Task, Long&gt; {
  
          List&lt;Task&gt; findByUser(User user);
  
      }
  </code></pre>
  
  <p>UserRepository.java</p>
  
  <pre><code>package org.home.mysystem.repository;
  
  import org.home.mysystem.entity.User;
  import org.springframework.data.jpa.repository.JpaRepository;
  
  public interface UserRepository extends JpaRepository&lt;User,String&gt; {
  
      User findOne(final String email);
  
  }
  </code></pre>
  
  <p>TaskService.java</p>
  
  <pre><code> package org.home.mysystem.service;
  
      import java.util.ArrayList;
      import java.util.List;
  
      import org.home.mysystem.entity.Role;
      import org.home.mysystem.entity.Task;
      import org.home.mysystem.entity.User;
      import org.home.mysystem.repository.TaskRepository;
      import org.home.mysystem.repository.UserRepository;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
      import org.springframework.stereotype.Service;
  
  
  
      @Service
      public class TaskService {
  
          @Autowired
          private TaskRepository taskRepository;
  
          public void addTask(Task task, User user) {
              task.setUser(user);
              taskRepository.save(task);
          }
  
          public List&lt;Task&gt;  findUserTask(User user){
  
              return taskRepository.findByUser(user);
          }
      }
  </code></pre>
  
  <p>UserService.java</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  import org.home.mysystem.entity.Role;
  import org.home.mysystem.entity.User;
  import org.home.mysystem.repository.UserRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  import org.springframework.stereotype.Service;
  
  
  
  @Service
  public class UserService {
  
      @Autowired
      private UserRepository userRepository;
  
      public void createUser(User user) {
          BCryptPasswordEncoder encoder=new BCryptPasswordEncoder();
          user.setPassword(encoder.encode(user.getPassword()));
          Role userRole=new Role("USER");
          List&lt;Role&gt; roles=new ArrayList&lt;&gt;();
          roles.add(userRole);
          user.setRoles(roles);
          userRepository.save(user);
      }
  
      public void createAdmin(User user) {
          BCryptPasswordEncoder encoder=new BCryptPasswordEncoder();
          user.setPassword(encoder.encode(user.getPassword()));
          Role userRole=new Role("ADMIN");
          List&lt;Role&gt; roles=new ArrayList&lt;&gt;();
          roles.add(userRole);
          user.setRoles(roles);
          userRepository.save(user);
      }
  
      public User findOne(String email) {
          return userRepository.findOne(email);
      }
  }
  </code></pre>
  
  <p>MyApplicationTest.java</p>
  
  <pre><code>package org.home.mysystem;
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertNotNull;
  
  import java.util.List;
  
  import org.home.mysystem.entity.Task;
  import org.home.mysystem.entity.User;
  import org.home.mysystem.service.TaskService;
  import org.home.mysystem.service.UserService;
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.test.context.SpringBootTest;
  import org.springframework.test.context.junit4.SpringRunner;
  
  @RunWith(SpringRunner.class)
  @SpringBootTest
  public class MySystemApplicationTests {
  
      @Autowired
      private UserService userService;
  
      @Autowired
      private TaskService taskService;
  
      @Before
      public void initDb() {
        {
            User newUser = new User("testUser@mail.com", "testUser", "123456");
            userService.createUser(newUser); 
        }
        {
            User newUser = new User("testAdmin@mail.com", "testAdmin", "123456");
            userService.createUser(newUser); 
        }
  
        Task userTask = new Task("03/01/2018", "00:11", "11:00", "You need to work today");
        User user = userService.findOne("testUser@mail.com");
        taskService.addTask(userTask, user);  
  
      }
  
      @Test
      public void testUser() {
          User user=userService.findOne("testUser@mail.com");
          assertNotNull(user);
          User admin=userService.findOne("testAdmin@mail.com");
          assertEquals(admin.getEmail(),"testAdmin@mail.com");
      }
  
      @Test
      public void testTask() {
          User user=userService.findOne("testUser@mail.com");
          List&lt;Task&gt; task=taskService.findUserTask(user);
          assertNotNull(task);
      }
  
      }
  </code></pre>