How to Fix: Error Creating Bean With Name:Unsatisfied Dependency Expressed Through Field

How to fix: Error creating bean with name : Unsatisfied dependency expressed through field

In your User class you declare id with int type

@Id
@Column(name = "id", unique = true)
private int id;

But in the repository interface, you declared Long

public interface UserRepository extends JpaRepository<User, Long> {}

So, in User class change type of id like,

@Id
@Column(name = "id", unique = true)
private Long id;

And avoid your new error, use @Service annotation at UserService interface like

@Service
public interface UserService {
List<User> getUsers();
}

Error creating bean with name 'weatherController': Unsatisfied dependency expressed through field 'weatherService';

In your WeatherRepository you have:

List<Weather> findByNameContaining(String value);

Now, this is a derived query method (more here).

The problem is your Weather entity does not have a property named name which you are using in your method.

The method should be:

List<Weather> findByCityContaining(String value);


Related Topics



Leave a reply



Submit