Skip to content

ashoksuryap/SpringMVCHibernateH2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpringBootMVCHibernate

To enable H2 console add spring.h2.console.enabled=true in application properties file

Reference: https://medium.com/@harittweets/how-to-connect-to-h2-database-during-development-testing-using-spring-boot-44bbb287570

http://localhost:8080/h2-console/login.jsp

Driver Class:org.h2.Driver

JDBC URL:jdbc:h2:mem:testdb

User Name:sa

Password:

To insert data on application start up,

@Component
public class DevBootstrap implements ApplicationListener<ContextRefreshedEvent> {
private EmployeeRepository employeeRepository;

    public DevBootstrap(EmployeeRepository employeeRepository) {
        this.employeeRepository = employeeRepository;
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        //create employee
        employeeRepository.save(employee);
    }
}

Thymeleaf : template will be in resources/templates folder with html extension. ex:- employees.html

Added spring boot dev tools

Added lombok dependency

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published