0

The full error is

Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'jwtRequestFilter': Unsatisfied dependency expressed through field 'jwtUserDetailsService': Error creating bean with name 'jwtUserDetailsService': Unsatisfied dependency expressed through field 'clientRepository': Error creating bean with name 'userRepo' defined in com.XX.ZZ.repo.UserRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'

As I have searched, apparently the error is in the entity, but I don't know how to fix it.

Question 1 and Question 2

package com.XX.ZZ.model;

import jakarta.persistence.*;
import lombok.Data;

@Entity
@Data
@Table
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "id")
    private Long id;
    @Column(name = "username")
    private String username;
    @Column(name = "password")
    private String hash;
}
package com.XX.ZZ.repo;

import com.XX.ZZ.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface UserRepo extends JpaRepository<User, Long> {

    Optional<User> findOneByUsername(String username);
}

application.properties

# MySQL configuration
spring.datasource.url=jdbc:mysql://localhost:3306/censored
spring.datasource.username=censored
spring.datasource.password=censored
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
# since Hibernate 6 there's no need to specify the MySQL dialect => https://vladmihalcea.com/hibernate-dialect/

# server port
server.port = 4400

# security - secret generated with 512bit security level with: https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx
custom.data.jwt.secret = censored
custom.data.jwt.expiration = 86400

Tell me if I need to provide more classes like the ones that appear in the error.

1 Answers1

0

Remove additional dependencies from maven pom, like jwt. 3 configurations you should have

@EnableJpaRepositories("com.project.marketplace.repositories")
@ComponentScan(basePackages = {"com.project"})
@EntityScan("com.project.marketplace.domain")
Armen Arzumanyan
  • 1,939
  • 3
  • 30
  • 56