错误:(15,30)java:不兼容的类型:com.sun.research.ws.wadl.Param无法转换为java.lang.annotation.annotation
我在运行java代码(spring)时遇到了这个错误错误:(15,30)java:不兼容的类型:com.sun.research.ws.wadl.Param无法转换为java.lang.annotation.annotation,java,angular,spring-boot,Java,Angular,Spring Boot,我在运行java代码(spring)时遇到了这个错误 错误:(15,30)java:不兼容的类型:com.sun.research.ws.wadl.Param无法转换为java.lang.annotation.annotation “电子邮件”和“密码”带有下划线并显示错误,这是我的代码: import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repos
错误:(15,30)java:不兼容的类型:com.sun.research.ws.wadl.Param无法转换为java.lang.annotation.annotation
“电子邮件”和“密码”带有下划线并显示错误,这是我的代码:
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import com.sun.research.ws.wadl.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.web.bind.annotation.RequestParam;
@RepositoryRestResource(path = "/test", collectionResourceRel = "test")
public interface JpaService extends JpaRepository<Person, Long> {
@RestResource(exported = false)
@Query("SELECT p FROM Person AS p WHERE p.email =:email AND p.password =:password")
public Person login(@Param("email") String email , @Param("password")String password);
@RestResource(exported = false)
@Query("SELECT p FROM Person AS p WHERE p.email =:email")
public Person getPersonByEmail(@Param("email") String email);
}
import org.springframework.data.jpa.repository.JpaRepository;
导入org.springframework.data.jpa.repository.Query;
导入com.sun.research.ws.wadl.Param;
导入org.springframework.data.rest.core.annotation.RepositoryRestResource;
导入org.springframework.data.rest.core.annotation.RestResource;
导入org.springframework.web.bind.annotation.RequestParam;
@RepositoryRestResource(path=“/test”,collectionResourceRel=“test”)
公共接口JpaService扩展了JpaRepository{
@RestResource(导出=假)
@查询(“从Person中选择p作为p,其中p.email=:email和p.password=:password”)
公众登录(@Param(“email”)字符串电子邮件,@Param(“密码”)字符串密码);
@RestResource(导出=假)
@查询(“从Person中选择p作为p,其中p.email=:email”)
公众人物getPersonByEmail(@Param(“电子邮件”)字符串电子邮件);
}
您的参数导入错误。改用org.springframework.data.repository.query.Param
。您导入的类没有注释,因此出现错误。我怀疑您使用了错误的导入。删除行import com.sun.research.ws.wadl.Param代码>并查看其他导入建议,它可能是spring的类之一。不客气。如果它回答了你的问题,那么你可能想接受它作为正确答案和/或投票。看见