[英]Error while using Jparepository
I was using JPA repository to get user data and store it in a list . 我正在使用JPA存储库来获取用户数据并将其存储在列表中。 Then is was going to iterate that list of users to get all the users. 然后是要迭代该用户列表以获取所有用户。 But there is an error in the forEach statement(Syntax error). 但是forEach语句中有一个错误(语法错误)。
code: 码:
package com.mohit.Services;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.mohit.Repo.userrepo;
import com.mohit.beans.users;
public class loginuser {
@Autowired
userrepo Repo;
public void loguser(users user){
String pass =user.getPass();
String uname =user.getName();
List<users> userlist=Repo.findAll();
forEach( users u : userlist){
}
}
}
There is no foreach
keyword in java, need to use for
, so you have error in source code, please try below code for cycle, instead of your's: java中没有foreach
关键字,需要使用for
,所以您在源代码中有错误,请尝试以下代码进行循环,而不是您的:
for(users u : userlist){
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.