java.lang.IllegalArgumentException:不是 Spring Boot

我的代码中出现以下错误


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;


@Repository

public 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;


@Service

public interface LocationService {

    Location saveLocation(Location location);

    Location updateLocation(Location location);

    void deleteLocation(Location location);

    Location getLocationById(int id);

    List<Location> getAllLocations();

}

这是我的 serviceImpl


package 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;


@Service

public 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);

    }



它显示我的位置实体类是非托管的,我尝试了各种答案但它不起作用,有什么帮助吗?


大话西游666
浏览 237回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java