I study spring rest

I made an authorization, I decided to make the answer to the server of the table content I do not understand what he does not like

UserServiceImpl:

@Component("userService") @Scope("session") public class UserServiceImpl implements UserService { private final UserRepository userRepository; private boolean logined; @Autowired public UserServiceImpl(UserRepository userRepository) { this.userRepository = userRepository; } public boolean login(String name, String password) { User user = userRepository.findOne(name); if(user == null) { return false; } boolean result = user.getPassword().equals(password); logined = result; return logined; } public void logout() { logined = false; } public boolean isLogined() { return logined; } } 

UserService:

 public interface UserService { boolean login(String name, String password); void logout(); boolean isLogined(); } 

UserRepository:

 @Repository public interface UserRepository extends CrudRepository<User,String> { } 

NewsRepository:

 @Repository public interface NewsRepository extends CrudRepository<News, String> { List<News> findAllNews(); } 

User:

 @Entity @Table(name = "user") public class User { @Id private String name; private String password; 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; } } 

News:

 @Entity @Table(name = "news") public class News { private long id; private String title; private String text; @Id public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getText() { return text; } public void setText(String text) { this.text = text; } } 

When creating newsController a in it, I understand it and an error occurs

 @RestController public class NewsController { @Autowired private NewsRepository rep; @RequestMapping("/news") public @ResponseBody java.util.List<News> index() { return rep.findAllNews(); } } 

Due to the fact that there is Autowired

 @RestController @Scope("session") public class LoginController { @Autowired private UserService userService; @RequestMapping("/**") public Object index() { return new Error("no access"); } @RequestMapping("/rest/login") public Object login(@RequestParam("username") String username, @RequestParam("password") String password) { String response; if(userService.login(username, password)) { response = Utitlity.constructJSON("login",true); return response; } return new Error("auth failed"); } @RequestMapping("/rest/logout") public Object logout() { if(!userService.isLogined()){ return new Error("no logined"); } userService.logout(); return new Response("loggedout"); } } 
  • one
    Bring the full error trace + spring configuration of the application. It is also a good idea to specify classes with the names of the packages in which they lie. - Temka, too,

0