Bean of type ‘org.hibernate.SessionFactory’ that could not be found

I have this security config class below. Since i am implementing jwt authentication, i commented out the old lines and added UserDetailsServiceImpl bean in place.

@Configuration
public class SecurityConfig {


    @Autowired
    private UserDetailsServiceImpl userDetailsService;

    @Autowired
    private JwtFilter jwtFilter;



//  @Bean
//  public UserDetailsManager userDetailsManager(DataSource dataSource) {
//      JdbcUserDetailsManager theUserDetailsManager = new JdbcUserDetailsManager(dataSource);
//      theUserDetailsManager
//              .setUsersByUsernameQuery("select user_email, user_password, enabled from chat_user where user_email=?");
//
//      theUserDetailsManager.setAuthoritiesByUsernameQuery("select user_email, authority from authorities where user_email=?");
//      return theUserDetailsManager;
//  }

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.authorizeHttpRequests(configurer -> configurer
                        .requestMatchers("/css/**", "/images/**").permitAll() //initially non authenticated users does not have access to css, so this is added
                        .requestMatchers("/showSignUpForm","/showLoginForm","/processSignUpForm").permitAll() // allow unauthenticated access to sign up page
                        .anyRequest().authenticated())
                        .addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
                        .formLogin(form -> form.loginPage("/showLoginForm")
                        .loginProcessingUrl("/authenticateTheUser")
                        .usernameParameter("user_email")
                        .passwordParameter("user_password")
                        .defaultSuccessUrl("/showChatPage", true)
                        .permitAll());
        return http.build();
    }
    
    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public AuthenticationManager authenticationManager(AuthenticationConfiguration auth) throws Exception {
        return auth.getAuthenticationManager();
    }

My UserDetailsServiceImpl looks like this

@Service
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private ChatUserService chatUserService;


    @Override
    public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
        ChatUser user = chatUserService.findByUserEmail(email);
        if (user != null) {
            return org.springframework.security.core.userdetails.User.builder()
                    .username(user.getUser_email())
                    .password(user.getUser_password())
                    .roles("ROLE_USER")
                    .build();
        }
        throw new UsernameNotFoundException("User not found with username: " + email);
    }
}

But now i’m getting this error

Description:

Field sessionFactory in com.springprojects.realtimechatapp.dao.ChatUserDAOImpl required a bean of type ‘org.hibernate.SessionFactory’ that could not be found.

The injection point has the following annotations:
– @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type ‘org.hibernate.SessionFactory’ in your configuration.

My ChatUserDaoImpl class looks like this:

@Repository
public class ChatUserDAOImpl implements ChatUserDAO{
    
    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public List<ChatUser> getchatUsers() {
        Session currentSession = sessionFactory.getCurrentSession();
        Query<ChatUser> theQuery = currentSession.createQuery("from ChatUser", ChatUser.class);
        List<ChatUser> chatUsers = theQuery.getResultList();
        return chatUsers;
    }

    @SuppressWarnings("deprecation")
    @Override
    public void saveChatUser(ChatUser theChatUser) {
        Session currentSession = sessionFactory.getCurrentSession();
        currentSession.saveOrUpdate(theChatUser);   
    }

    @Override
    public ChatUser getChatUser(int theId) {
        Session currentSession = sessionFactory.getCurrentSession();
        ChatUser theChatUser = currentSession.get(ChatUser.class, theId);
        return theChatUser;
    }

    @Override
    public void deleteChatUser(int theId) {
        Session currentSession = sessionFactory.getCurrentSession();
        Query theQuery = currentSession.createQuery("delete from ChatUser where chat_id=:chatUserId");
        theQuery.setParameter("chatUserId", theId);
        theQuery.executeUpdate();
    }

    @Override
    public ChatUser findByUsername(String username) {
        Session currentSession = sessionFactory.getCurrentSession();
        Query<ChatUser> theQuery = currentSession.createQuery("from ChatUser where user_name=:u", ChatUser.class);
        theQuery.setParameter("u", username);
        try {
            return theQuery.getSingleResult();
        } catch (NoResultException nre) {
            return null;
        }
    }

    @Override
    public ChatUser findByUserEmail(String email) {
        Session currentSession = sessionFactory.getCurrentSession();
        Query<ChatUser> theQuery = currentSession.createQuery("from ChatUser where user_email=:e", ChatUser.class);
        theQuery.setParameter("e", email);
        try {
            return theQuery.getSingleResult();
        } catch (NoResultException nre) {
            return null;
        }
    }
}

Please help what can I do here differently to make it work?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật