Example — Spring Mvc With Hibernate

@Bean public ViewResolver viewResolver() { InternalResourceViewResolver resolver = new InternalResourceViewResolver(); resolver.setViewClass(JstlView.class); resolver.setPrefix("/WEB-INF/views/"); resolver.setSuffix(".jsp"); return resolver; } } package com.example.config; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import;

public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { spring mvc with hibernate example

@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Long id; } } package com.example.config

@Controller @RequestMapping("/users") public class UserController { @Override public List&lt

private Properties hibernateProperties() { Properties properties = new Properties(); properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL8Dialect"); properties.put("hibernate.show_sql", "true"); properties.put("hibernate.hbm2ddl.auto", "update"); properties.put("hibernate.format_sql", "true"); return properties; } } package com.example.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView;

@Override public List<User> getAllUsers() { return userDAO.getAllUsers(); }

@Autowired private SessionFactory sessionFactory;