Spring Not a Managed Type class

Viewed 1234

Note: I`m not using spring boot

All the errors in here

Error creating bean with name 'writeData': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in com.aykut.repository.UserRepository defined in @EnableJpaRepositories declared on SpringConfig: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.aykut.modal.User

Error creating bean with name 'userRepository' defined in com.aykut.repository.UserRepository defined in @EnableJpaRepositories declared on SpringConfig: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.aykut.modal.User

Not a managed type: class com.aykut.modal.User

Project tree

User class

@Entity
public class User {
    @Id
    Integer id;
    String name;
    String surname;

    public User(Integer id, String name, String surname) {
        this.id = id;
        this.name = name;
        this.surname = surname;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }
}

Spring config class

@Configuration
@EnableJpaAuditing
@EnableJpaRepositories(basePackages = {
        "com.aykut.repository"
})
@ComponentScan(basePackages = { "com.aykut"})
public class SpringConfig {
}

User Repository class

@Repository
public interface UserRepository extends JpaRepository<User, Integer> {

}

I am just trying to write data to my Postgres database using the spring batch.

0 Answers
Related