при попытке ининциализировать репозиторий, у меня выходит ошибка
код контроллера MainController:
@Controller
public class MainController {
public final FlagRepository flagRepository;
@Autowired
public MainController(FlagRepository flagRepository) {
this.flagRepository = flagRepository;
}
@GetMapping("/")
public String changeFlag(){
// Flag flag = flagRepository.findById(1L);
// flag.setFlag(0);
// flagRepository.save(flag.getId());
return "main";
}
// ...
}
код интерфейса FlagRepository:
import com.blrmyfc.ComputerVision.domain.Flag;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface FlagRepository extends JpaRepository<Long, Flag> {
Flag findById(Long l);
}
Класс сущность Flag:
import javax.persistence.*;
@Entity
@Table(name = "flag")
public class Flag {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private int flag;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public int getFlag() {
return flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public Flag() {
}
public Flag(int flag) {
this.flag = flag;
}
}
Лог ошибок:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainController' defined in file [/home/blurmayface/Документы/ComputerVision/target/classes/com/blrmyfc/ComputerVision/controller/MainController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flagRepository' defined in com.blrmyfc.ComputerVision.repo.FlagRepository defined in @EnableJpaRepositories declared on ComputerVisionApplication: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Long
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flagRepository' defined in com.blrmyfc.ComputerVision.repo.FlagRepository defined in @EnableJpaRepositories declared on ComputerVisionApplication: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Long
java.lang.IllegalArgumentException: Not a managed type: class java.lang.Long
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:582) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
Вообще не ясно в чем проблема :(