我的代碼中出現以下錯誤org.springframework.beans.factory.UnsatisfiedDependencyException:創建名為“locationServiceImpl”的 bean 時出錯:通過方法“setLocationrepo”參數 0 表示的不滿意依賴;嵌套異常是 org.springframework.beans.factory.BeanCreationException:創建名為“locationRepository”的 bean 時出錯:調用 init 方法失??;嵌套異常是 java.lang.IllegalArgumentException: Not a managed type: class com.logan.location.entities.Location這是我的存儲庫界面package com.logan.location.repos;import org.springframework.data.jpa.repository.JpaRepository;import org.springframework.stereotype.Repository;import com.logan.location.entities.Location;@Repositorypublic interface LocationRepository extends JpaRepository<Location, Integer> {}這是我的服務接口package com.logan.location.service;import java.util.List;import org.springframework.stereotype.Service;import com.logan.location.entities.Location;@Servicepublic interface LocationService { Location saveLocation(Location location); Location updateLocation(Location location); void deleteLocation(Location location); Location getLocationById(int id); List<Location> getAllLocations();}這是我的 serviceImplpackage com.logan.location.service;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import com.logan.location.entities.Location;import com.logan.location.repos.LocationRepository;@Servicepublic class LocationServiceImpl implements LocationService { private LocationRepository locationrepo; @Autowired public void setLocationrepo(LocationRepository locationrepo) { this.locationrepo = locationrepo; } public Location saveLocation(Location location) { // TODO Auto-generated method stub return locationrepo.save(location); } public Location updateLocation(Location location) { // TODO Auto-generated method stub return locationrepo.save(location); }它顯示我的位置實體類是非托管的,我嘗試了各種答案但它不起作用,有什么幫助嗎?
添加回答
舉報
0/150
提交
取消