spring boot integrates spring Data JPA and freemarker

1. Introduction to spring Data JPA

Is an alternative to hibernate a framework for the role of the database.

2. Integration

1. Import dependency



2. Create pojo object

3. Create dao layer

package com.offcn.dao;

import com.offcn.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;

public interface UserDao extends JpaRepository<User,Integer> {

There is no need to write some simple sql statements after integration.

4. Configure scan path in configuration class

package com.offcn;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class DemoApplication {

    public static void main(String[] args) {

5. Database information is required in the application.properties configuration file

spring.datasource.url=jdbc:mysql:// = GMT

6. freemarker can be used for later echo data

1. Import dependency


2. Create templates folder under resources, under which you can write pages, similar to HTML style.


        <title>user surface</title>
        <table border="1px">
                    <td>User name</td>
                <#list userList as user>


Tags: Java Spring MySQL Database JDBC

Posted on Tue, 05 Nov 2019 08:35:35 -0800 by soniared2002